Search in sources :

Example 1 with BridgeLifecycleException

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

the class BridgesServiceImpl method deleteBridge.

@Transactional
@Override
public void deleteBridge(String id, String customerId) {
    Long processorsCount = processorService.getProcessorsCount(id, customerId);
    if (processorsCount > 0) {
        // See https://issues.redhat.com/browse/MGDOBR-43
        throw new BridgeLifecycleException("It is not possible to delete a Bridge instance with active Processors.");
    }
    Bridge bridge = findByIdAndCustomerId(id, customerId);
    bridge.setStatus(ManagedResourceStatus.DEPROVISION);
    LOGGER.info("Bridge with id '{}' for customer '{}' has been marked for deletion", bridge.getId(), bridge.getCustomerId());
}
Also used : BridgeLifecycleException(com.redhat.service.bridge.infra.exceptions.definitions.user.BridgeLifecycleException) Bridge(com.redhat.service.bridge.manager.models.Bridge) Transactional(javax.transaction.Transactional)

Example 2 with BridgeLifecycleException

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

the class SendToBridgeActionTransformerTest method beforeEach.

@BeforeEach
void beforeEach() {
    reset(bridgesServiceMock);
    when(bridgesServiceMock.getReadyBridge(BRIDGE_ID, TEST_CUSTOMER_ID)).thenReturn(bridge);
    when(bridgesServiceMock.getReadyBridge(OTHER_BRIDGE_ID, TEST_CUSTOMER_ID)).thenReturn(otherBridge);
    when(bridgesServiceMock.getReadyBridge(UNAVAILABLE_BRIDGE_ID, TEST_CUSTOMER_ID)).thenThrow(new BridgeLifecycleException("Unavailable bridge"));
    when(bridgesServiceMock.getReadyBridge(not(or(eq(UNAVAILABLE_BRIDGE_ID), or(eq(BRIDGE_ID), eq(OTHER_BRIDGE_ID)))), eq(TEST_CUSTOMER_ID))).thenThrow(new ItemNotFoundException("Bridge not found"));
    when(bridgesServiceMock.getReadyBridge(any(), not(eq(TEST_CUSTOMER_ID)))).thenThrow(new ItemNotFoundException("Customer not found"));
}
Also used : BridgeLifecycleException(com.redhat.service.bridge.infra.exceptions.definitions.user.BridgeLifecycleException) ItemNotFoundException(com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BridgeLifecycleException (com.redhat.service.bridge.infra.exceptions.definitions.user.BridgeLifecycleException)2 ItemNotFoundException (com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException)1 Bridge (com.redhat.service.bridge.manager.models.Bridge)1 Transactional (javax.transaction.Transactional)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1