// Tests_SRS_AMQPSIOTHUBCONNECTIONBASEHANDLER_14_035: [If the Connection was remotely closed // abnormally, the event handler shall complete the sent message CompletableFuture with a new // HandlerException.] @Test public void onConnectionRemoteCloseClosesAbnormallyCompletesMessageExceptionally( @Mocked final CompletableFuture<Integer> mockFuture) { final String hostName = "test.host.name"; final String deviceId = "test-deviceId"; final String userName = "******"; final String sasToken = "test-token"; new NonStrictExpectations() { { mockEvent.getConnection(); result = mockConnection; mockConnection.getCondition(); result = new ErrorCondition(); } }; AmqpsIotHubConnectionBaseHandler handler = new AmqpsIotHubConnectionBaseHandler( hostName, userName, sasToken, deviceId, mockIotHubConnection); Deencapsulation.setField(handler, "currentSentMessageFuture", mockFuture); handler.onConnectionRemoteClose(mockEvent); new Verifications() { { mockFuture.completeExceptionally((HandlerException) any); } }; }