Search in sources :

Example 21 with DuplicateKeyException

use of org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException in project open-kilda by telstra.

the class YFlowCreateServiceTest method shouldFailOnErrorDuringDraftYFlowCreation.

@Test
public void shouldFailOnErrorDuringDraftYFlowCreation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    // given
    YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
    YFlowRepository repository = setupYFlowRepositorySpy();
    doThrow(new RuntimeException(injectedErrorMessage)).when(repository).add(ArgumentMatchers.argThat(argument -> argument.getYFlowId().equals(request.getYFlowId())));
    preparePathComputation("test_flow_1", buildFirstSubFlowPathPair());
    preparePathComputation("test_flow_2", buildSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
    // when
    processRequest(request);
    // then
    verifyNorthboundErrorResponse(yFlowCreateHubCarrier, ErrorType.INTERNAL_ERROR);
    verifyNoSpeakerInteraction(yFlowCreateHubCarrier);
    verifyYFlowIsAbsent(request.getYFlowId());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers(org.mockito.ArgumentMatchers) FlowPath(org.openkilda.model.FlowPath) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) YFlowResponse(org.openkilda.messaging.command.yflow.YFlowResponse) RunWith(org.junit.runner.RunWith) FlowStatus(org.openkilda.model.FlowStatus) ResourceAllocationException(org.openkilda.wfm.share.flow.resources.ResourceAllocationException) RecoverableException(org.openkilda.pce.exception.RecoverableException) Mockito.doThrow(org.mockito.Mockito.doThrow) SpeakerRequest(org.openkilda.floodlight.api.request.SpeakerRequest) ArgumentMatcher(org.mockito.ArgumentMatcher) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) InstallSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest) Mockito.doAnswer(org.mockito.Mockito.doAnswer) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException) FlowDeleteService(org.openkilda.wfm.topology.flowhs.service.FlowDeleteService) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Before(org.junit.Before) FlowGenericCarrier(org.openkilda.wfm.topology.flowhs.service.FlowGenericCarrier) DuplicateKeyException(org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException) ErrorType(org.openkilda.messaging.error.ErrorType) Mockito.times(org.mockito.Mockito.times) CommandContext(org.openkilda.wfm.CommandContext) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) FlowCreateService(org.openkilda.wfm.topology.flowhs.service.FlowCreateService) Mockito.verify(org.mockito.Mockito.verify) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) SwitchId(org.openkilda.model.SwitchId) Ignore(org.junit.Ignore) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest) GetPathsResult(org.openkilda.pce.GetPathsResult) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Aggregations

DuplicateKeyException (org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException)21 Before (org.junit.Before)3 Test (org.junit.Test)3 RunWith (org.junit.runner.RunWith)3 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)3 Mock (org.mockito.Mock)3 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 Mockito.times (org.mockito.Mockito.times)3 Mockito.verify (org.mockito.Mockito.verify)3 MockitoJUnitRunner (org.mockito.junit.MockitoJUnitRunner)3 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)3 CommandContext (org.openkilda.wfm.CommandContext)3 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertFalse (org.junit.Assert.assertFalse)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Ignore (org.junit.Ignore)2 ArgumentMatchers (org.mockito.ArgumentMatchers)2 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)2 Mockito.doThrow (org.mockito.Mockito.doThrow)2 Mockito.when (org.mockito.Mockito.when)2