package com.connectsdk.service.webos;


import com.connectsdk.service.WebOSTVService;
import com.connectsdk.service.capability.listeners.ResponseListener;
import com.connectsdk.service.command.ServiceCommand;
import com.connectsdk.service.command.ServiceCommandError;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import java.net.URI;

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class WebOSTVServiceSocketClientTest {

    private WebOSTVServiceSocketClient socketClient;

    @Before
    public void setUp() {
        WebOSTVService service = Mockito.mock(WebOSTVService.class);
        URI uri = URI.create("http://127.0.0.1/");
        socketClient = new WebOSTVServiceSocketClient(service, uri);
    }

    @Test
    public void test403ErrorShouldNotCloseSocket() {
        ResponseListener<Object> listener = Mockito.mock(ResponseListener.class);
        ServiceCommand command = new ServiceCommand(null, null, (Object)null, listener);
        socketClient.requests.put(11, command);
        socketClient.state = WebOSTVServiceSocketClient.State.REGISTERED;
        socketClient.onMessage(" {\"type\":\"error\",\"id\":\"11\",\"error\":" +
                "\"403 access denied\",\"payload\":{}}");
        Assert.assertEquals(WebOSTVServiceSocketClient.State.REGISTERED, socketClient.getState());
        Mockito.verify(listener).onError(Mockito.any(ServiceCommandError.class));
    }
}

@@ -994,171 +994,166 @@
     
-ResponseListener%3CObject%3E listener = Mockito.mock(ResponseListener.class);%0A        ServiceCommand command = new ServiceCommand(null, null, (Object)null, listener
+ServiceCommand command = new ServiceCommand(null, null, (Object)null, null);%0A        WebOSTVServiceSocketClient spySocketClient = Mockito.spy(socketClient
 );%0A
+%0A
     
@@ -1149,32 +1149,35 @@
 ent);%0A%0A        s
+pyS
 ocketClient.requ
@@ -1200,32 +1200,35 @@
 mand);%0A        s
+pyS
 ocketClient.stat
@@ -1277,32 +1277,35 @@
 TERED;%0A        s
+pyS
 ocketClient.onMe
@@ -1414,24 +1414,25 @@
 ad%5C%22:%7B%7D%7D%22);%0A
+%0A
         Asse
@@ -1493,16 +1493,19 @@
 TERED, s
+pyS
 ocketCli
@@ -1548,64 +1548,49 @@
 ify(
-listener).onError(Mockito.any(ServiceCommandError.class)
+spySocketClient, Mockito.times(0)).close(
 );%0A 

Verify that close method is not invoked in WebOSTVServiceSocketClientTest