Search in sources :

Example 21 with RepositoryFactory

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

the class RerouteServiceTest method processManualRerouteRequest.

@Test
public void processManualRerouteRequest() {
    FlowRepository flowRepository = mock(FlowRepository.class);
    when(flowRepository.findById(regularFlow.getFlowId())).thenReturn(Optional.of(regularFlow));
    RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
    when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
    PersistenceManager persistenceManager = mock(PersistenceManager.class);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
    RerouteService rerouteService = new RerouteService(persistenceManager);
    FlowRerouteRequest request = new FlowRerouteRequest(regularFlow.getFlowId(), true, true, false, Collections.emptySet(), "reason", true);
    rerouteService.processRerouteRequest(carrier, CORRELATION_ID, request);
    FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(regularFlow.getPriority()).timeCreate(regularFlow.getTimeCreate()).affectedIsl(Collections.emptySet()).force(true).effectivelyDown(true).reason("reason").build();
    verify(carrier).emitManualRerouteCommand(eq(regularFlow.getFlowId()), eq(expected));
}
Also used : FlowRepository(org.openkilda.persistence.repositories.FlowRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Test(org.junit.Test)

Example 22 with RepositoryFactory

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

the class YFlowValidatorTest method setup.

@BeforeClass
public static void setup() {
    RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
    when(repositoryFactory.createFlowRepository()).thenReturn(mock(FlowRepository.class));
    when(repositoryFactory.createSwitchRepository()).thenReturn(mock(SwitchRepository.class));
    when(repositoryFactory.createIslRepository()).thenReturn(mock(IslRepository.class));
    when(repositoryFactory.createSwitchPropertiesRepository()).thenReturn(mock(SwitchPropertiesRepository.class));
    when(repositoryFactory.createFlowMirrorPathRepository()).thenReturn(mock(FlowMirrorPathRepository.class));
    when(repositoryFactory.createYFlowRepository()).thenReturn(mock(YFlowRepository.class));
    PersistenceManager persistenceManager = mock(PersistenceManager.class);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    yFlowValidator = new YFlowValidator(persistenceManager);
}
Also used : SwitchPropertiesRepository(org.openkilda.persistence.repositories.SwitchPropertiesRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) IslRepository(org.openkilda.persistence.repositories.IslRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) FlowMirrorPathRepository(org.openkilda.persistence.repositories.FlowMirrorPathRepository) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) BeforeClass(org.junit.BeforeClass)

Example 23 with RepositoryFactory

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

the class IslLatencyBolt method init.

@Override
protected void init() {
    TransactionManager transactionManager = persistenceManager.getTransactionManager();
    RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory();
    islLatencyService = new IslLatencyService(transactionManager, repositoryFactory, latencyUpdateInterval, latencyUpdateTimeRange);
}
Also used : TransactionManager(org.openkilda.persistence.tx.TransactionManager) IslLatencyService(org.openkilda.wfm.topology.isllatency.service.IslLatencyService) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory)

Aggregations

RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)23 PersistenceManager (org.openkilda.persistence.PersistenceManager)13 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)11 FlowRepository (org.openkilda.persistence.repositories.FlowRepository)11 Test (org.junit.Test)10 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)10 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)6 Before (org.junit.Before)5 BeforeClass (org.junit.BeforeClass)5 PathSegmentRepository (org.openkilda.persistence.repositories.PathSegmentRepository)5 SwitchRepository (org.openkilda.persistence.repositories.SwitchRepository)4 RerouteAffectedFlows (org.openkilda.messaging.command.reroute.RerouteAffectedFlows)3 PathNode (org.openkilda.messaging.info.event.PathNode)3 FlowPath (org.openkilda.model.FlowPath)3 IslRepository (org.openkilda.persistence.repositories.IslRepository)3 PropertiesBasedConfigurationProvider (org.openkilda.config.provider.PropertiesBasedConfigurationProvider)2 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)2 IslEndpoint (org.openkilda.model.IslEndpoint)2 PathSegment (org.openkilda.model.PathSegment)2 SwitchId (org.openkilda.model.SwitchId)2