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);
}
Aggregations