// Path: src/main/java/com/tsystems/readyapi/plugin/websocket/Utils.java
// public static String bytesToHexString(byte[] buf) {
//     final String decimals = "0123456789ABCDEF";
//     if (buf == null)
//         return null;
//     char[] r = new char[buf.length * 2];
//     for (int i = 0; i < buf.length; ++i) {
//         r[i * 2] = decimals.charAt((buf[i] & 0xf0) >> 4);
//         r[i * 2 + 1] = decimals.charAt(buf[i] & 0x0f);
//     }
//     return new String(r);
// }


import static com.tsystems.readyapi.plugin.websocket.Utils.bytesToHexString;
import java.beans.PropertyChangeEvent;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.config.TestAssertionConfig;
import com.eviware.soapui.config.TestStepConfig;
import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
import com.eviware.soapui.impl.wsdl.support.AbstractNonHttpMessageExchange;
import com.eviware.soapui.impl.wsdl.support.IconAnimator;
import com.eviware.soapui.impl.wsdl.support.assertions.AssertableConfig;
import com.eviware.soapui.impl.wsdl.support.assertions.AssertionsSupport;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStepResult;
import com.eviware.soapui.impl.wsdl.teststeps.assertions.TestAssertionRegistry;
import com.eviware.soapui.model.iface.Interface;
import com.eviware.soapui.model.iface.Response;
import com.eviware.soapui.model.iface.SubmitContext;
import com.eviware.soapui.model.support.DefaultTestStepProperty;
import com.eviware.soapui.model.support.TestStepBeanProperty;
import com.eviware.soapui.model.testsuite.Assertable;
import com.eviware.soapui.model.testsuite.AssertionsListener;
import com.eviware.soapui.model.testsuite.TestAssertion;
import com.eviware.soapui.model.testsuite.TestCaseRunContext;
import com.eviware.soapui.model.testsuite.TestCaseRunner;
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.model.testsuite.TestStepResult;
import com.eviware.soapui.monitor.TestMonitor;
import com.eviware.soapui.plugins.auto.PluginTestStep;
import com.eviware.soapui.support.StringUtils;
import com.eviware.soapui.support.UISupport;
import com.eviware.soapui.support.xml.XmlObjectConfigurationReader;
import com.google.common.base.Charsets;
        disabledStepIcon = UISupport.createImageIcon("com/tsystems/readyapi/plugin/websocket/disabled_receive_step.png");

        iconAnimator = new IconAnimator<ReceiveTestStep>(this, "com/tsystems/readyapi/plugin/websocket/receive_step_base.png",
                "com/tsystems/readyapi/plugin/websocket/receive_step.png", 5);
    }

    @Override
    public TestAssertion moveAssertion(int ix, int offset) {
        WsdlMessageAssertion assertion = assertionsSupport.getAssertionAt(ix);
        try {
            return assertionsSupport.moveAssertion(ix, offset);
        } finally {
            assertion.release();
            updateState();
        }
    }

    private void onInvalidPayload(byte[] payload, WsdlTestStepResult errors) {
        if (payload == null || payload.length == 0) {
            setReceivedMessage(null);
            errors.addMessage(String.format(
                    "Unable to extract a content of \"%s\" type from the message, because its payload is empty.",
                    expectedMessageType));
            return;
        }
        String text;
        String actualFormat = "hexadecimal digits sequence";
        if (payload.length >= 3 && payload[0] == (byte) 0xef && payload[1] == (byte) 0xbb && payload[2] == (byte) 0xbf) {
            text = bytesToString(payload, 3, Charsets.UTF_8);
            if (text == null)
// Path: src/main/java/com/tsystems/readyapi/plugin/websocket/Utils.java
// public static String bytesToHexString(byte[] buf) {
//     final String decimals = "0123456789ABCDEF";
//     if (buf == null)
//         return null;
//     char[] r = new char[buf.length * 2];
//     for (int i = 0; i < buf.length; ++i) {
//         r[i * 2] = decimals.charAt((buf[i] & 0xf0) >> 4);
//         r[i * 2 + 1] = decimals.charAt(buf[i] & 0x0f);
//     }
//     return new String(r);
// }


// Path: src/main/java/com/tsystems/readyapi/plugin/websocket/ReceiveTestStep.java
import static com.tsystems.readyapi.plugin.websocket.Utils.bytesToHexString;
import java.beans.PropertyChangeEvent;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.config.TestAssertionConfig;
import com.eviware.soapui.config.TestStepConfig;
import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
import com.eviware.soapui.impl.wsdl.support.AbstractNonHttpMessageExchange;
import com.eviware.soapui.impl.wsdl.support.IconAnimator;
import com.eviware.soapui.impl.wsdl.support.assertions.AssertableConfig;
import com.eviware.soapui.impl.wsdl.support.assertions.AssertionsSupport;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStepResult;
import com.eviware.soapui.impl.wsdl.teststeps.assertions.TestAssertionRegistry;
import com.eviware.soapui.model.iface.Interface;
import com.eviware.soapui.model.iface.Response;
import com.eviware.soapui.model.iface.SubmitContext;
import com.eviware.soapui.model.support.DefaultTestStepProperty;
import com.eviware.soapui.model.support.TestStepBeanProperty;
import com.eviware.soapui.model.testsuite.Assertable;
import com.eviware.soapui.model.testsuite.AssertionsListener;
import com.eviware.soapui.model.testsuite.TestAssertion;
import com.eviware.soapui.model.testsuite.TestCaseRunContext;
import com.eviware.soapui.model.testsuite.TestCaseRunner;
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.model.testsuite.TestStepResult;
import com.eviware.soapui.monitor.TestMonitor;
import com.eviware.soapui.plugins.auto.PluginTestStep;
import com.eviware.soapui.support.StringUtils;
import com.eviware.soapui.support.UISupport;
import com.eviware.soapui.support.xml.XmlObjectConfigurationReader;
import com.google.common.base.Charsets;

        disabledStepIcon = UISupport.createImageIcon("com/tsystems/readyapi/plugin/websocket/disabled_receive_step.png");

        iconAnimator = new IconAnimator<ReceiveTestStep>(this, "com/tsystems/readyapi/plugin/websocket/receive_step_base.png",
                "com/tsystems/readyapi/plugin/websocket/receive_step.png", 5);
    }

    @Override
    public TestAssertion moveAssertion(int ix, int offset) {
        WsdlMessageAssertion assertion = assertionsSupport.getAssertionAt(ix);
        try {
            return assertionsSupport.moveAssertion(ix, offset);
        } finally {
            assertion.release();
            updateState();
        }
    }

    private void onInvalidPayload(byte[] payload, WsdlTestStepResult errors) {
        if (payload == null || payload.length == 0) {
            setReceivedMessage(null);
            errors.addMessage(String.format(
                    "Unable to extract a content of \"%s\" type from the message, because its payload is empty.",
                    expectedMessageType));
            return;
        }
        String text;
        String actualFormat = "hexadecimal digits sequence";
        if (payload.length >= 3 && payload[0] == (byte) 0xef && payload[1] == (byte) 0xbb && payload[2] == (byte) 0xbf) {
            text = bytesToString(payload, 3, Charsets.UTF_8);
            if (text == null)
                text = bytesToHexString(payload);