Search in sources :

Example 1 with LagLogicalPortRepository

use of org.openkilda.persistence.repositories.LagLogicalPortRepository in project open-kilda by telstra.

the class SwitchValidateServiceImplTest method setUp.

@Before
public void setUp() {
    RepositoryFactory repositoryFactory = Mockito.mock(RepositoryFactory.class);
    FlowPathRepository flowPathRepository = Mockito.mock(FlowPathRepository.class);
    SwitchRepository switchRepository = Mockito.mock(SwitchRepository.class);
    when(switchRepository.findById(eq(SWITCH_ID))).thenReturn(Optional.of(SWITCH_1));
    when(switchRepository.findById(eq(SWITCH_ID_MISSING))).thenReturn(Optional.empty());
    LagLogicalPortRepository lagLogicalPortRepository = Mockito.mock(LagLogicalPortRepository.class);
    when(repositoryFactory.createFlowPathRepository()).thenReturn(flowPathRepository);
    when(repositoryFactory.createSwitchRepository()).thenReturn(switchRepository);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    service = new SwitchValidateServiceImpl(carrier, persistenceManager, validationService, ruleManager);
    request = SwitchValidateRequest.builder().switchId(SWITCH_ID).processMeters(true).build();
    flowSpeakerData = FlowSpeakerData.builder().ofVersion(OfVersion.OF_13).cookie(new Cookie(1L)).table(OfTable.INPUT).priority(10).match(emptySet()).instructions(Instructions.builder().build()).flags(emptySet()).build();
    meterSpeakerData = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(10000).burst(10500).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    when(validationService.validateRules(any(), any(), any())).thenReturn(new ValidateRulesResult(newHashSet(flowSpeakerData.getCookie().getValue()), emptySet(), emptySet(), emptySet()));
    when(validationService.validateMeters(any(), any(), any())).thenReturn(new ValidateMetersResult(emptyList(), emptyList(), emptyList(), emptyList()));
}
Also used : LagLogicalPortRepository(org.openkilda.persistence.repositories.LagLogicalPortRepository) Cookie(org.openkilda.model.cookie.Cookie) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) MeterId(org.openkilda.model.MeterId) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 MeterId (org.openkilda.model.MeterId)1 Cookie (org.openkilda.model.cookie.Cookie)1 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)1 LagLogicalPortRepository (org.openkilda.persistence.repositories.LagLogicalPortRepository)1 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)1 SwitchRepository (org.openkilda.persistence.repositories.SwitchRepository)1 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)1 ValidateRulesResult (org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult)1