Search in sources :

Example 1 with LockKeeperService

use of org.openkilda.testing.service.lockkeeper.LockKeeperService in project open-kilda by telstra.

the class StubServiceFactory method getLockKeeperStub.

/**
 * Get a stub for {@link LockKeeperService}. The instance is tied to the factory state.
 */
public LockKeeperService getLockKeeperStub() {
    LockKeeperService serviceMock = mock(LockKeeperService.class);
    List<ASwitchFlow> aswitchFlows = topologyDefinition.getIslsForActiveSwitches().stream().filter(isl -> isl.getAswitch() != null).map(isl -> {
        ASwitchFlow asw = isl.getAswitch();
        return Arrays.asList(new ASwitchFlow(asw.getInPort(), asw.getOutPort()), new ASwitchFlow(asw.getOutPort(), asw.getInPort()));
    }).flatMap(List::stream).collect(toList());
    when(serviceMock.getAllFlows()).thenReturn(aswitchFlows);
    return serviceMock;
}
Also used : Arrays(java.util.Arrays) SwitchChangeType(org.openkilda.messaging.info.event.SwitchChangeType) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Collections.singletonList(java.util.Collections.singletonList) Switch(org.openkilda.testing.model.topology.TopologyDefinition.Switch) FlowApplyActions(org.openkilda.testing.service.floodlight.model.FlowApplyActions) NorthboundService(org.openkilda.testing.service.northbound.NorthboundService) Map(java.util.Map) LocalTime(java.time.LocalTime) Exam(org.openkilda.testing.service.traffexam.model.Exam) SwitchLocationDto(org.openkilda.northbound.dto.v1.switches.SwitchLocationDto) FlowEntry(org.openkilda.testing.service.floodlight.model.FlowEntry) RulesValidationResult(org.openkilda.northbound.dto.v1.switches.RulesValidationResult) Collections.emptyList(java.util.Collections.emptyList) FlowDto(org.openkilda.messaging.model.FlowDto) FlowMatchField(org.openkilda.testing.service.floodlight.model.FlowMatchField) ASwitchFlow(org.openkilda.testing.service.lockkeeper.model.ASwitchFlow) Host(org.openkilda.testing.service.traffexam.model.Host) List(java.util.List) Stream(java.util.stream.Stream) FlowPairDto(org.openkilda.messaging.model.FlowPairDto) RulesSyncResult(org.openkilda.northbound.dto.v1.switches.RulesSyncResult) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) ExamReport(org.openkilda.testing.service.traffexam.model.ExamReport) MeterBand(org.openkilda.testing.service.floodlight.model.MeterBand) SerializationUtils(org.apache.commons.lang3.SerializationUtils) HashMap(java.util.HashMap) IslChangeType(org.openkilda.messaging.info.event.IslChangeType) ArrayList(java.util.ArrayList) Answer(org.mockito.stubbing.Answer) FlowEntriesMap(org.openkilda.testing.service.floodlight.model.FlowEntriesMap) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) MetersEntriesMap(org.openkilda.testing.service.floodlight.model.MetersEntriesMap) TopologyDefinition(org.openkilda.testing.model.topology.TopologyDefinition) FloodlightService(org.openkilda.testing.service.floodlight.FloodlightService) Mockito.when(org.mockito.Mockito.when) PathNode(org.openkilda.messaging.info.event.PathNode) MeterEntry(org.openkilda.testing.service.floodlight.model.MeterEntry) TraffExamService(org.openkilda.testing.service.traffexam.TraffExamService) Collectors.toList(java.util.stream.Collectors.toList) SwitchId(org.openkilda.model.SwitchId) LockKeeperService(org.openkilda.testing.service.lockkeeper.LockKeeperService) SwitchEntry(org.openkilda.testing.service.floodlight.model.SwitchEntry) FlowState(org.openkilda.messaging.payload.flow.FlowState) SwitchDto(org.openkilda.northbound.dto.v1.switches.SwitchDto) Bandwidth(org.openkilda.testing.service.traffexam.model.Bandwidth) FlowInstructions(org.openkilda.testing.service.floodlight.model.FlowInstructions) LockKeeperService(org.openkilda.testing.service.lockkeeper.LockKeeperService) ASwitchFlow(org.openkilda.testing.service.lockkeeper.model.ASwitchFlow)

Aggregations

LocalTime (java.time.LocalTime)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors.toList (java.util.stream.Collectors.toList)1 Stream (java.util.stream.Stream)1 SerializationUtils (org.apache.commons.lang3.SerializationUtils)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 Answer (org.mockito.stubbing.Answer)1 IslChangeType (org.openkilda.messaging.info.event.IslChangeType)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 SwitchChangeType (org.openkilda.messaging.info.event.SwitchChangeType)1 FlowDto (org.openkilda.messaging.model.FlowDto)1