Search in sources :

Example 1 with TraffExamService

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;
}
Also used : TraffExamService(org.openkilda.testing.service.traffexam.TraffExamService) Bandwidth(org.openkilda.testing.service.traffexam.model.Bandwidth) ExamReport(org.openkilda.testing.service.traffexam.model.ExamReport) Host(org.openkilda.testing.service.traffexam.model.Host) Exam(org.openkilda.testing.service.traffexam.model.Exam)

Aggregations

TraffExamService (org.openkilda.testing.service.traffexam.TraffExamService)1 Bandwidth (org.openkilda.testing.service.traffexam.model.Bandwidth)1 Exam (org.openkilda.testing.service.traffexam.model.Exam)1 ExamReport (org.openkilda.testing.service.traffexam.model.ExamReport)1 Host (org.openkilda.testing.service.traffexam.model.Host)1