@Test
public void testSendCommandsToRouter()
        throws AgentUnavailableException, OperationTimedoutException, ResourceUnavailableException {

    // Prepare
    NetworkHelperImpl nwHelperUT = spy(this.nwHelper);
    VirtualRouter vr = mock(VirtualRouter.class);
    when(vr.getHostId()).thenReturn(HOST_ID);
    doReturn(true).when(nwHelperUT).checkRouterVersion(vr);
    Commands commands = mock(Commands.class);
    when(commands.size()).thenReturn(3);
    Answer answer1 = mock(Answer.class);
    Answer answer2 = mock(Answer.class);
    Answer answer3 = mock(Answer.class);
    // In the second iteration it should match and return, without invoking the third
    Answer[] answers = {answer1, answer2, answer3};
    when(answer1.getResult()).thenReturn(true);
    when(answer2.getResult()).thenReturn(false);
    when(answer3.getResult()).thenReturn(false);
    when(this.agentManager.send(HOST_ID, commands)).thenReturn(answers);
    // Execute
    final boolean result = nwHelperUT.sendCommandsToRouter(vr, commands);
    // Assert
    verify(this.agentManager, times(1)).send(HOST_ID, commands);
    verify(answer1, times(1)).getResult();
    verify(answer2, times(1)).getResult();
    verify(answer3, times(0)).getResult();
    assertFalse(result);
}