// Path: src/main/java/pl/joegreen/sergeants/api/test/FakeSocket.java
// public class FakeSocket implements Socket{
// 
//     public final List<Event> receivedEvents = new CopyOnWriteArrayList<>();
//     public final Map<String, Consumer<Object[]>> registeredListeners = new ConcurrentHashMap<>();
//     boolean connected = false;
// 
//     public List<Event> getReceivedEventsByName(String name) {
//         return receivedEvents.stream().filter(event -> event.name.equals(name)).collect(Collectors.toList());
//     }
// 
//     public void injectEvent(Event event){
//         getListener(event.getName()).accept(event.getArguments());
//     }
// 
//     @Override
//     public boolean connected() {
//         return connected;
//     }
// 
//     @Override
//     public void once(String event, Consumer<Object[]> socketListener) {
//         registeredListeners.put(event, args -> {
//             socketListener.accept(args);
//             registeredListeners.remove(event);
//         });
//     }
// 
//     @Override
//     public void on(String event, Consumer<Object[]> socketListener) {
//         registeredListeners.put(event, socketListener);
//     }
// 
//     @Override
//     public void connect() {
//         connected = true;
//         getListener("connect").accept(new Object[]{});
//     }
// 
//     @Override
//     public void disconnect() {
//         connected = false;
//         getListener("disconnect").accept(new Object[]{});
//     }
// 
// 
//     private Consumer<Object[]> getListener(String connect) {
//         return registeredListeners.getOrDefault(connect, (args) -> {});
//     }
// 
// 
//     @Override
//     public void emit(String name, Object[] args) {
//         receivedEvents.add(new Event(name, args));
//     }
// 
// 
//     @Value
//     public static class Event{
//         private String name;
//         private Object[] arguments;
// 
//         public Event(String name, Object... arguments ){
//             this.name = name;
//             this.arguments = arguments;
//         }
//     }
// 
// 
// 
// }


import pl.joegreen.sergeants.api.test.FakeSocket;
import org.json.JSONException;
import org.json.JSONTokener;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static java.util.stream.Collectors.toList;
package pl.joegreen.sergeants;




public class TestUtils {

    /**
     * SocketIO java client is using json.org json objects
     */
    public static Object asJsonOrgObject(String eventJson)  {
        try {
            return new JSONTokener(eventJson).nextValue();
        } catch (JSONException e) {
            throw new RuntimeException("Cannot deserialize:" + eventJson, e);
        }
    }

// Path: src/main/java/pl/joegreen/sergeants/api/test/FakeSocket.java
// public class FakeSocket implements Socket{
// 
//     public final List<Event> receivedEvents = new CopyOnWriteArrayList<>();
//     public final Map<String, Consumer<Object[]>> registeredListeners = new ConcurrentHashMap<>();
//     boolean connected = false;
// 
//     public List<Event> getReceivedEventsByName(String name) {
//         return receivedEvents.stream().filter(event -> event.name.equals(name)).collect(Collectors.toList());
//     }
// 
//     public void injectEvent(Event event){
//         getListener(event.getName()).accept(event.getArguments());
//     }
// 
//     @Override
//     public boolean connected() {
//         return connected;
//     }
// 
//     @Override
//     public void once(String event, Consumer<Object[]> socketListener) {
//         registeredListeners.put(event, args -> {
//             socketListener.accept(args);
//             registeredListeners.remove(event);
//         });
//     }
// 
//     @Override
//     public void on(String event, Consumer<Object[]> socketListener) {
//         registeredListeners.put(event, socketListener);
//     }
// 
//     @Override
//     public void connect() {
//         connected = true;
//         getListener("connect").accept(new Object[]{});
//     }
// 
//     @Override
//     public void disconnect() {
//         connected = false;
//         getListener("disconnect").accept(new Object[]{});
//     }
// 
// 
//     private Consumer<Object[]> getListener(String connect) {
//         return registeredListeners.getOrDefault(connect, (args) -> {});
//     }
// 
// 
//     @Override
//     public void emit(String name, Object[] args) {
//         receivedEvents.add(new Event(name, args));
//     }
// 
// 
//     @Value
//     public static class Event{
//         private String name;
//         private Object[] arguments;
// 
//         public Event(String name, Object... arguments ){
//             this.name = name;
//             this.arguments = arguments;
//         }
//     }
// 
// 
// 
// }


// Path: src/test/java/pl/joegreen/sergeants/TestUtils.java
import pl.joegreen.sergeants.api.test.FakeSocket;
import org.json.JSONException;
import org.json.JSONTokener;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static java.util.stream.Collectors.toList;

package pl.joegreen.sergeants;




public class TestUtils {

    /**
     * SocketIO java client is using json.org json objects
     */
    public static Object asJsonOrgObject(String eventJson)  {
        try {
            return new JSONTokener(eventJson).nextValue();
        } catch (JSONException e) {
            throw new RuntimeException("Cannot deserialize:" + eventJson, e);
        }
    }

    public static List<FakeSocket.Event> readEventsFromClassPathFile(String fileName) throws URISyntaxException, IOException {