Source:
<code>public void testAttachDebugger() throws Exception { debugger.setDebugSession(null); final String debugSessionJson = "debugSession"; doReturn(debugSessionJson).when(dtoFactory).toJson(debugSessionDto); doReturn(mock(StartActionDto.class)).when(dtoFactory).createDto(StartActionDto.class); Map<String, String> connectionProperties = mock(Map.class); Promise<DebugSessionDto> promiseDebuggerInfo = mock(Promise.class); MethodNameConfigurator methodNameConfigurator = mock(MethodNameConfigurator.class); ParamsConfigurator paramsConfigurator = mock(ParamsConfigurator.class); ResultConfiguratorFromOne resultConfiguratorFromOne = mock(ResultConfiguratorFromOne.class); OperationConfiguratorOneToNone operationConfiguratorOneToNone = mock(OperationConfiguratorOneToNone.class); <START> doReturn(methodNameConfigurator).when(configurator).newConfiguration(); <END> doReturn(methodNameConfigurator).when(configurator).newConfiguration(); doReturn(paramsConfigurator).when(methodNameConfigurator).methodName(anyString()); doReturn(resultConfiguratorFromOne).when(paramsConfigurator).paramsAsDto(anyObject()); doReturn(operationConfiguratorOneToNone).when(resultConfiguratorFromOne).noResult(); doReturn(promiseDebuggerInfo).when(service).connect("id", connectionProperties); doReturn(promiseVoid).when(promiseDebuggerInfo).then((Function<DebugSessionDto, Void>)any()); doReturn(promiseVoid).when(promiseVoid).catchError((Operation<PromiseError>)any()); Promise<Void> result = debugger.connect(connectionProperties); assertEquals(promiseVoid, result); verify(promiseDebuggerInfo).then(argumentCaptorFunctionJavaDebugSessionVoid.capture()); argumentCaptorFunctionJavaDebugSessionVoid.getValue().apply(debugSessionDto); verify(promiseVoid).catchError(operationPromiseErrorCaptor.capture()); try { operationPromiseErrorCaptor.getValue().apply(promiseError); fail("Operation Exception expected"); } catch (OperationException e) { verify(promiseError).getMessage(); verify(promiseError).getCause(); } verify(observer).onDebuggerAttached(debuggerDescriptor, promiseVoid); assertTrue(debugger.isConnected()); verify(localStorage).setItem(eq(AbstractDebugger.LOCAL_STORAGE_DEBUGGER_SESSION_KEY), eq(debugSessionJson)); }</code><technical_language>duplicate line</technical_language>

Target:
public void testAttachDebugger() throws Exception { debugger.setDebugSession(null); final String debugSessionJson = "debugSession"; doReturn(debugSessionJson).when(dtoFactory).toJson(debugSessionDto); doReturn(mock(StartActionDto.class)).when(dtoFactory).createDto(StartActionDto.class); Map<String, String> connectionProperties = mock(Map.class); Promise<DebugSessionDto> promiseDebuggerInfo = mock(Promise.class); MethodNameConfigurator methodNameConfigurator = mock(MethodNameConfigurator.class); ParamsConfigurator paramsConfigurator = mock(ParamsConfigurator.class); ResultConfiguratorFromOne resultConfiguratorFromOne = mock(ResultConfiguratorFromOne.class); OperationConfiguratorOneToNone operationConfiguratorOneToNone = mock(OperationConfiguratorOneToNone.class); doReturn(methodNameConfigurator).when(configurator).newConfiguration(); doReturn(paramsConfigurator).when(methodNameConfigurator).methodName(anyString()); doReturn(resultConfiguratorFromOne).when(paramsConfigurator).paramsAsDto(anyObject()); doReturn(operationConfiguratorOneToNone).when(resultConfiguratorFromOne).noResult(); doReturn(promiseDebuggerInfo).when(service).connect("id", connectionProperties); doReturn(promiseVoid).when(promiseDebuggerInfo).then((Function<DebugSessionDto, Void>)any()); doReturn(promiseVoid).when(promiseVoid).catchError((Operation<PromiseError>)any()); Promise<Void> result = debugger.connect(connectionProperties); assertEquals(promiseVoid, result); verify(promiseDebuggerInfo).then(argumentCaptorFunctionJavaDebugSessionVoid.capture()); argumentCaptorFunctionJavaDebugSessionVoid.getValue().apply(debugSessionDto); verify(promiseVoid).catchError(operationPromiseErrorCaptor.capture()); try { operationPromiseErrorCaptor.getValue().apply(promiseError); fail("Operation Exception expected"); } catch (OperationException e) { verify(promiseError).getMessage(); verify(promiseError).getCause(); } verify(observer).onDebuggerAttached(debuggerDescriptor, promiseVoid); assertTrue(debugger.isConnected()); verify(localStorage).setItem(eq(AbstractDebugger.LOCAL_STORAGE_DEBUGGER_SESSION_KEY), eq(debugSessionJson)); }