package com.example.fitbot;


import static org.junit.Assert.assertEquals;

import com.example.fitbot.util.server.WebSocketConnectionHandler;

import org.junit.Test;

/**
 * Created on 07/05/2024 at 18:27
 * by Luca Warmenhoven.
 */
public class WebSocketMessageParsingTest {



    @Test
    public void parseWebSocketMessage() {

        String reference = "abcdef";
        final byte[] encoded = {
                (byte) 129, (byte) 134, (byte) 167,
                (byte) 225, (byte) 225, (byte) 210,
                (byte) 198, (byte) 131, (byte) 130,
                (byte) 182, (byte) 194, (byte) 135
        };
        String decoded = "";
        try {
            decoded = WebSocketConnectionHandler.decodeWebSocketMessage(encoded);
        } catch (Exception e) {
            System.err.println("Error occurred whilst attempting to parse input" + e.getMessage());
        }
        assertEquals(reference, decoded);
    }
}
