ActionDBAccessor db = mock(ActionDBAccessor.class);
when(db.getStagesInProgress()).thenReturn(stages);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
String host = (String) invocation.getArguments()[0];
String role = (String) invocation.getArguments()[3];
//HostRoleCommand command = stages.get(0).getHostRoleCommand(host, role);
for (HostRoleCommand command : stages.get(0).getOrderedHostRoleCommands()) {
if (command.getHostName().equals(host) && command.getRole().name()
.equals(role)) {
command.setStatus(HostRoleStatus.TIMEDOUT);
}
}
return null;
}
}).when(db).timeoutHostRole(anyString(), anyLong(), anyLong(), anyString());
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Long requestId = (Long) invocation.getArguments()[0];
for (Stage stage : stages) {
if (requestId.equals(stage.getRequestId())) {