@@ -0,0 +1,3448 @@
+package io.digdag.standards.command;%0A%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.fasterxml.jackson.databind.node.JsonNodeFactory;%0Aimport com.fasterxml.jackson.databind.node.ObjectNode;%0Aimport com.google.common.collect.ImmutableMap;%0Aimport io.digdag.spi.CommandContext;%0Aimport io.digdag.spi.CommandExecutor;%0Aimport io.digdag.spi.CommandRequest;%0Aimport io.digdag.spi.CommandStatus;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.util.Collections;%0A%0Apublic class MockNonBlockingCommandExecutor%0A        implements CommandExecutor%0A%7B%0A    private static final JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;%0A%0A    private final ObjectMapper mapper;%0A%0A    public MockNonBlockingCommandExecutor(final ObjectMapper mapper)%0A    %7B%0A        this.mapper = mapper;%0A    %7D%0A%0A    @Override%0A    public CommandStatus run(CommandContext context, CommandRequest request)%0A            throws IOException%0A    %7B%0A        final DefaultCommandStatus status = new DefaultCommandStatus();%0A        status.isFinished = false; // by default%0A        status.statusCode = 0;%0A        status.ioDirectory = request.getIoDirectory().toString();%0A        status.json = (ObjectNode) jsonNodeFactory.objectNode()%0A                .setAll(ImmutableMap.of(%0A                        %22is_finished%22, jsonNodeFactory.booleanNode(status.isFinished),%0A                        %22status_code%22, jsonNodeFactory.numberNode(status.statusCode),%0A                        %22io_directory%22, jsonNodeFactory.textNode(status.ioDirectory)%0A                ));%0A        return status;%0A    %7D%0A%0A    @Override%0A    public CommandStatus poll(CommandContext context, ObjectNode currentStatusJson)%0A            throws IOException%0A    %7B%0A        final DefaultCommandStatus status = new DefaultCommandStatus();%0A        status.isFinished = currentStatusJson.get(%22is_finished%22).booleanValue();%0A        status.statusCode = currentStatusJson.get(%22status_code%22).intValue();%0A        status.ioDirectory = currentStatusJson.get(%22io_directory%22).textValue();%0A        status.json = currentStatusJson;%0A%0A        if (status.isFinished) %7B%0A            // write result to output.json%0A            final Path outputPath = context.getLocalProjectPath().resolve(status.getIoDirectory()).resolve(%22output.json%22);%0A            try (final OutputStream out = Files.newOutputStream(outputPath)) %7B%0A                mapper.writeValue(out, ImmutableMap.of(%22params%22,%0A                        ImmutableMap.of(%0A                                %22subtask_config%22, Collections.emptyMap(),%0A                                %22export_params%22, Collections.emptyMap(),%0A                                %22store_params%22, Collections.emptyMap()%0A                        )));%0A            %7D%0A        %7D%0A%0A        return status;%0A    %7D%0A%0A    public static class DefaultCommandStatus%0A            implements CommandStatus%0A    %7B%0A        private boolean isFinished;%0A        private int statusCode;%0A        private String ioDirectory;%0A        private ObjectNode json;%0A%0A        @Override%0A        public boolean isFinished()%0A        %7B%0A            return isFinished;%0A        %7D%0A%0A        @Override%0A        public int getStatusCode()%0A        %7B%0A            return statusCode;%0A        %7D%0A%0A        @Override%0A        public String getIoDirectory()%0A        %7B%0A            return ioDirectory;%0A        %7D%0A%0A        @Override%0A        public ObjectNode toJson()%0A        %7B%0A            return json;%0A        %7D%0A    %7D%0A%7D%0A

Add MockNonBlockingCommandExecutor for unit testing of new SPI