use of org.openkilda.testing.service.traffexam.TraffExamService in project open-kilda by telstra.
the class StubServiceFactory method getTraffExamStub.
/**
* Get a stub for {@link TraffExamService}. The instance is tied to the factory state.
*/
public TraffExamService getTraffExamStub() {
TraffExamService serviceMock = mock(TraffExamService.class);
when(serviceMock.hostByName(any())).thenAnswer(invocation -> {
String hostName = (String) invocation.getArguments()[0];
Host host = mock(Host.class);
when(host.getName()).thenReturn(hostName);
return host;
});
when(serviceMock.waitExam(any())).thenAnswer(invocation -> {
Exam exam = (Exam) invocation.getArguments()[0];
ExamReport report = mock(ExamReport.class);
when(report.hasError()).thenReturn(false);
when(report.hasTraffic()).thenReturn(flows.containsKey(exam.getFlow().getId()));
when(report.getBandwidth()).thenReturn(new Bandwidth(exam.getFlow().getMaximumBandwidth()));
return report;
});
return serviceMock;
}
Aggregations