Search in sources :

Example 6 with ItemNotFoundException

use of com.redhat.service.smartevents.infra.exceptions.definitions.user.ItemNotFoundException in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method cleanUp.

@BeforeEach
public void cleanUp() {
    reset(bridgesServiceMock);
    reset(processorDAO);
    Bridge bridge = createReadyBridge();
    Processor processor = createReadyProcessor();
    Processor provisioningProcessor = createProvisioningProcessor();
    Processor failedProcessor = createFailedProcessor();
    Processor errorHandlerProcessor = createErrorHandlerProcessor();
    when(bridgesServiceMock.getBridge(DEFAULT_BRIDGE_ID)).thenReturn(bridge);
    when(bridgesServiceMock.getBridge(not(eq(DEFAULT_BRIDGE_ID)))).thenThrow(new ItemNotFoundException("Bridge not found"));
    when(bridgesServiceMock.getBridge(DEFAULT_BRIDGE_ID, DEFAULT_CUSTOMER_ID)).thenReturn(bridge);
    when(bridgesServiceMock.getBridge(not(eq(DEFAULT_BRIDGE_ID)), eq(DEFAULT_CUSTOMER_ID))).thenThrow(new ItemNotFoundException("Bridge not found"));
    when(bridgesServiceMock.getBridge(any(), not(eq(DEFAULT_CUSTOMER_ID)))).thenThrow(new ItemNotFoundException("Bridge not found"));
    when(bridgesServiceMock.getReadyBridge(DEFAULT_BRIDGE_ID, DEFAULT_CUSTOMER_ID)).thenReturn(bridge);
    when(bridgesServiceMock.getReadyBridge(NOT_READY_BRIDGE_ID, DEFAULT_CUSTOMER_ID)).thenThrow(new BridgeLifecycleException("Bridge not ready"));
    when(bridgesServiceMock.getReadyBridge(not(or(eq(DEFAULT_BRIDGE_ID), eq(NOT_READY_BRIDGE_ID))), eq(DEFAULT_CUSTOMER_ID))).thenThrow(new ItemNotFoundException("Bridge not found"));
    when(processorDAO.findById(DEFAULT_PROCESSOR_ID)).thenReturn(processor);
    when(processorDAO.findByBridgeIdAndName(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_NAME)).thenReturn(processor);
    when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(processor);
    when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, PROVISIONING_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(provisioningProcessor);
    when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, FAILED_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(failedProcessor);
    when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, ERROR_HANDLER_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(errorHandlerProcessor);
    when(processorDAO.findUserVisibleByBridgeIdAndCustomerId(eq(DEFAULT_BRIDGE_ID), eq(DEFAULT_CUSTOMER_ID), any())).thenReturn(new ListResult<>(List.of(processor, provisioningProcessor, failedProcessor), 0, 3));
    when(processorDAO.countByBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_CUSTOMER_ID)).thenReturn(3L);
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) BridgeLifecycleException(com.redhat.service.smartevents.infra.exceptions.definitions.user.BridgeLifecycleException) Bridge(com.redhat.service.smartevents.manager.models.Bridge) ItemNotFoundException(com.redhat.service.smartevents.infra.exceptions.definitions.user.ItemNotFoundException) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ItemNotFoundException (com.redhat.service.smartevents.infra.exceptions.definitions.user.ItemNotFoundException)6 Processor (com.redhat.service.smartevents.manager.models.Processor)4 Bridge (com.redhat.service.smartevents.manager.models.Bridge)3 Transactional (javax.transaction.Transactional)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 BridgeLifecycleException (com.redhat.service.smartevents.infra.exceptions.definitions.user.BridgeLifecycleException)2 ProcessorLifecycleException (com.redhat.service.smartevents.infra.exceptions.definitions.user.ProcessorLifecycleException)1