// Path: src/se/vidstige/jadb/JadbException.java
// public class JadbException extends Exception {
// 
//     public JadbException(String message) {
//         super(message);
//     }
// 
//     private static final long serialVersionUID = -3879283786835654165L;
// }
// 
// Path: src/se/vidstige/jadb/RemoteFile.java
// public class RemoteFile {
//     private final String path;
// 
//     public RemoteFile(String path) { this.path = path; }
// 
//     public String getName() { throw new UnsupportedOperationException(); }
//     public int getSize() { throw new UnsupportedOperationException(); }
//     public int getLastModified() { throw new UnsupportedOperationException(); }
//     public boolean isDirectory() { throw new UnsupportedOperationException(); }
// 
//     public String getPath() { return path;}
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         RemoteFile that = (RemoteFile) o;
//         return path.equals(that.path);
//     }
// 
//     @Override
//     public int hashCode() {
//         return path.hashCode();
//     }
// }
// 
// Path: src/se/vidstige/jadb/server/AdbDeviceResponder.java
// public interface AdbDeviceResponder {
//     String getSerial();
//     String getType();
// 
//     void filePushed(RemoteFile path, int mode, ByteArrayOutputStream buffer) throws JadbException;
//     void filePulled(RemoteFile path, ByteArrayOutputStream buffer) throws JadbException, IOException;
// 
//     void shell(String command, DataOutputStream stdout, DataInput stdin) throws IOException;
//     void enableIpCommand(String ip, DataOutputStream outputStream) throws IOException;
// 
//     List<RemoteFile> list(String path) throws IOException;
// }
// 
// Path: src/se/vidstige/jadb/server/AdbResponder.java
// public interface AdbResponder {
//     void onCommand(String command);
// 
//     int getVersion();
// 
//     List<AdbDeviceResponder> getDevices();
// }
// 
// Path: src/se/vidstige/jadb/server/AdbServer.java
// public class AdbServer extends SocketServer {
// 
//     public static final int DEFAULT_PORT = 15037;
//     private final AdbResponder responder;
// 
//     public AdbServer(AdbResponder responder) {
//         this(responder, DEFAULT_PORT);
//     }
// 
//     public AdbServer(AdbResponder responder, int port) {
//         super(port);
//         this.responder = responder;
//     }
// 
//     @Override
//     protected Runnable createResponder(Socket socket) {
//         return new AdbProtocolHandler(socket, responder);
//     }
// }


import se.vidstige.jadb.JadbException;
import se.vidstige.jadb.RemoteFile;
import se.vidstige.jadb.server.AdbDeviceResponder;
import se.vidstige.jadb.server.AdbResponder;
import se.vidstige.jadb.server.AdbServer;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ProtocolException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
    }

    private DeviceResponder findBySerial(String serial) {
        for (DeviceResponder d : devices) {
            if (d.getSerial().equals(serial)) return d;
        }
        return null;
    }

    public ExpectationBuilder expectPush(String serial, RemoteFile path) {
        return findBySerial(serial).expectPush(path);
    }

    public ExpectationBuilder expectPull(String serial, RemoteFile path) {
        return findBySerial(serial).expectPull(path);
    }

    public DeviceResponder.ShellExpectation expectShell(String serial, String commands) {
        return findBySerial(serial).expectShell(commands);
    }

    public void expectTcpip(String serial, Integer port) {
        findBySerial(serial).expectTcpip(port);
    }

    public DeviceResponder.ListExpectation expectList(String serial, String remotePath) {
        return findBySerial(serial).expectList(remotePath);
    }

    @Override
// Path: src/se/vidstige/jadb/JadbException.java
// public class JadbException extends Exception {
// 
//     public JadbException(String message) {
//         super(message);
//     }
// 
//     private static final long serialVersionUID = -3879283786835654165L;
// }
// 
// Path: src/se/vidstige/jadb/RemoteFile.java
// public class RemoteFile {
//     private final String path;
// 
//     public RemoteFile(String path) { this.path = path; }
// 
//     public String getName() { throw new UnsupportedOperationException(); }
//     public int getSize() { throw new UnsupportedOperationException(); }
//     public int getLastModified() { throw new UnsupportedOperationException(); }
//     public boolean isDirectory() { throw new UnsupportedOperationException(); }
// 
//     public String getPath() { return path;}
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         RemoteFile that = (RemoteFile) o;
//         return path.equals(that.path);
//     }
// 
//     @Override
//     public int hashCode() {
//         return path.hashCode();
//     }
// }
// 
// Path: src/se/vidstige/jadb/server/AdbDeviceResponder.java
// public interface AdbDeviceResponder {
//     String getSerial();
//     String getType();
// 
//     void filePushed(RemoteFile path, int mode, ByteArrayOutputStream buffer) throws JadbException;
//     void filePulled(RemoteFile path, ByteArrayOutputStream buffer) throws JadbException, IOException;
// 
//     void shell(String command, DataOutputStream stdout, DataInput stdin) throws IOException;
//     void enableIpCommand(String ip, DataOutputStream outputStream) throws IOException;
// 
//     List<RemoteFile> list(String path) throws IOException;
// }
// 
// Path: src/se/vidstige/jadb/server/AdbResponder.java
// public interface AdbResponder {
//     void onCommand(String command);
// 
//     int getVersion();
// 
//     List<AdbDeviceResponder> getDevices();
// }
// 
// Path: src/se/vidstige/jadb/server/AdbServer.java
// public class AdbServer extends SocketServer {
// 
//     public static final int DEFAULT_PORT = 15037;
//     private final AdbResponder responder;
// 
//     public AdbServer(AdbResponder responder) {
//         this(responder, DEFAULT_PORT);
//     }
// 
//     public AdbServer(AdbResponder responder, int port) {
//         super(port);
//         this.responder = responder;
//     }
// 
//     @Override
//     protected Runnable createResponder(Socket socket) {
//         return new AdbProtocolHandler(socket, responder);
//     }
// }


// Path: test/se/vidstige/jadb/test/fakes/FakeAdbServer.java
import se.vidstige.jadb.JadbException;
import se.vidstige.jadb.RemoteFile;
import se.vidstige.jadb.server.AdbDeviceResponder;
import se.vidstige.jadb.server.AdbResponder;
import se.vidstige.jadb.server.AdbServer;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ProtocolException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

    }

    private DeviceResponder findBySerial(String serial) {
        for (DeviceResponder d : devices) {
            if (d.getSerial().equals(serial)) return d;
        }
        return null;
    }

    public ExpectationBuilder expectPush(String serial, RemoteFile path) {
        return findBySerial(serial).expectPush(path);
    }

    public ExpectationBuilder expectPull(String serial, RemoteFile path) {
        return findBySerial(serial).expectPull(path);
    }

    public DeviceResponder.ShellExpectation expectShell(String serial, String commands) {
        return findBySerial(serial).expectShell(commands);
    }

    public void expectTcpip(String serial, Integer port) {
        findBySerial(serial).expectTcpip(port);
    }

    public DeviceResponder.ListExpectation expectList(String serial, String remotePath) {
        return findBySerial(serial).expectList(remotePath);
    }

    @Override
    public List<AdbDeviceResponder> getDevices() {