use of org.openkilda.testing.service.traffexam.model.ExamReport 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;
}
use of org.openkilda.testing.service.traffexam.model.ExamReport in project open-kilda by telstra.
the class TraffExamServiceImpl method fetchReport.
@Override
public ExamReport fetchReport(Exam exam) throws NoResultsFoundException, ExamNotFinishedException {
ExamResources resources = retrieveExamResources(exam);
EndpointReport producerReport = fetchEndpointReport(resources.getProducer());
EndpointReport consumerReport;
try {
consumerReport = fetchEndpointReport(resources.getConsumer());
} catch (ExamNotFinishedException e) {
if (producerReport.getError() == null) {
throw e;
}
consumerReport = new EndpointReport("Don't wait for consumer report due to error on producer side");
}
return new ExamReport(exam, producerReport, consumerReport);
}
Aggregations