Search in sources :

Example 1 with InternalPlatformException

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

the class ProcessorServiceTest method createConnectorFailureOnExternalConnectorCreation.

@Test
public void createConnectorFailureOnExternalConnectorCreation() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    BaseAction slackAction = createSlackAction();
    ProcessorRequest processorRequest = new ProcessorRequest("ManagedConnectorProcessor", slackAction);
    doThrow(new InternalPlatformException(createFailureErrorMessageFor("errorDeletingConnector"), new RuntimeException("error"))).when(connectorsApiClient).deleteConnector(anyString());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), processorRequest);
    waitForProcessorAndConnectorToFail(processor);
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) InternalPlatformException(com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 2 with InternalPlatformException

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

the class ProcessorServiceTest method testDeleteConnectorFailureOnExternalConnectorDestruction.

@Test
public void testDeleteConnectorFailureOnExternalConnectorDestruction() {
    Bridge bridge = createPersistBridge(ManagedResourceStatus.READY);
    Processor processor = Fixtures.createProcessor(bridge, "bridgeTestDelete", ManagedResourceStatus.READY);
    ConnectorEntity connector = Fixtures.createConnector(processor, "connectorToBeDeleted", ManagedResourceStatus.READY, "topicName");
    processorDAO.persist(processor);
    connectorsDAO.persist(connector);
    // Emulate successful External Connector creation
    Connector externalConnector = new Connector();
    final ConnectorStatusStatus externalConnectorStatus = new ConnectorStatusStatus();
    externalConnectorStatus.setState(ConnectorState.READY);
    externalConnector.setStatus(externalConnectorStatus);
    when(connectorsApiClient.getConnector(any())).thenReturn(externalConnector);
    doThrow(new InternalPlatformException(createFailureErrorMessageFor("errorDeletingConnector"), new RuntimeException("error"))).when(connectorsApiClient).deleteConnector(anyString());
    processorService.deleteProcessor(bridge.getId(), processor.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    reloadAssertProcessorIsInStatus(processor, DEPROVISION);
    waitForProcessorAndConnectorToFail(processor);
    verify(rhoasService, never()).deleteTopicAndRevokeAccessFor(any(), any());
    verify(connectorsApiClient, atLeast(1)).deleteConnector(anyString());
    assertShardAsksForProcessorToBeDeletedDoesNotInclude(processor);
}
Also used : Connector(com.openshift.cloud.api.connector.models.Connector) Processor(com.redhat.service.bridge.manager.models.Processor) InternalPlatformException(com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException) ConnectorEntity(com.redhat.service.bridge.manager.models.ConnectorEntity) Bridge(com.redhat.service.bridge.manager.models.Bridge) ConnectorStatusStatus(com.openshift.cloud.api.connector.models.ConnectorStatusStatus) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 3 with InternalPlatformException

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

the class ProcessorServiceTest method testDeleteConnectorFailureOnKafkaTopicDeletion.

@Test
public void testDeleteConnectorFailureOnKafkaTopicDeletion() {
    Bridge bridge = createPersistBridge(ManagedResourceStatus.READY);
    Processor processor = Fixtures.createProcessor(bridge, "bridgeTestDelete", ManagedResourceStatus.READY);
    ConnectorEntity connector = Fixtures.createConnector(processor, "connectorToBeDeleted", ManagedResourceStatus.READY, "topicName");
    processorDAO.persist(processor);
    connectorsDAO.persist(connector);
    // Emulate successful External Connector creation
    Connector externalConnector = new Connector();
    final ConnectorStatusStatus externalConnectorStatus = new ConnectorStatusStatus();
    externalConnectorStatus.setState(ConnectorState.READY);
    externalConnector.setStatus(externalConnectorStatus);
    when(connectorsApiClient.getConnector(any())).thenReturn(externalConnector);
    // Emulate successful External Connector deletion
    doAnswer(i -> {
        externalConnectorStatus.setState(ConnectorState.DELETED);
        return null;
    }).when(connectorsApiClient).deleteConnector(any());
    doThrow(new InternalPlatformException(createFailureErrorMessageFor("errorTopic"), new RuntimeException("error"))).when(rhoasService).deleteTopicAndRevokeAccessFor(anyString(), any());
    processorService.deleteProcessor(bridge.getId(), processor.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    reloadAssertProcessorIsInStatus(processor, DEPROVISION);
    waitForProcessorAndConnectorToFail(processor);
    verify(rhoasService, atLeast(1)).deleteTopicAndRevokeAccessFor(eq("topicName"), eq(RhoasTopicAccessType.PRODUCER));
    verify(connectorsApiClient, atLeast(1)).deleteConnector(anyString());
    assertShardAsksForProcessorToBeDeletedDoesNotInclude(processor);
}
Also used : Connector(com.openshift.cloud.api.connector.models.Connector) Processor(com.redhat.service.bridge.manager.models.Processor) InternalPlatformException(com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException) ConnectorEntity(com.redhat.service.bridge.manager.models.ConnectorEntity) Bridge(com.redhat.service.bridge.manager.models.Bridge) ConnectorStatusStatus(com.openshift.cloud.api.connector.models.ConnectorStatusStatus) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 4 with InternalPlatformException

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

the class ProcessorServiceTest method createConnectorFailureOnKafkaTopicCreation.

@Test
public void createConnectorFailureOnKafkaTopicCreation() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    BaseAction slackAction = createSlackAction();
    ProcessorRequest processorRequest = new ProcessorRequest("ManagedConnectorProcessor", slackAction);
    when(rhoasService.createTopicAndGrantAccessFor(anyString(), any())).thenThrow(new InternalPlatformException(createFailureErrorMessageFor("errorTopic"), new RuntimeException("error")));
    when(connectorsApiClient.createConnector(any(ConnectorRequest.class))).thenReturn(new Connector());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), processorRequest);
    waitForProcessorAndConnectorToFail(processor);
    verify(rhoasService, atLeast(1)).createTopicAndGrantAccessFor(anyString(), eq(RhoasTopicAccessType.PRODUCER));
    verify(connectorsApiClient, never()).createConnector(any(ConnectorRequest.class));
}
Also used : Connector(com.openshift.cloud.api.connector.models.Connector) ConnectorRequest(com.openshift.cloud.api.connector.models.ConnectorRequest) Processor(com.redhat.service.bridge.manager.models.Processor) InternalPlatformException(com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

InternalPlatformException (com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException)4 Bridge (com.redhat.service.bridge.manager.models.Bridge)4 Processor (com.redhat.service.bridge.manager.models.Processor)4 QuarkusTest (io.quarkus.test.junit.QuarkusTest)4 Test (org.junit.jupiter.api.Test)4 Connector (com.openshift.cloud.api.connector.models.Connector)3 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)2 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)2 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)2 ConnectorEntity (com.redhat.service.bridge.manager.models.ConnectorEntity)2 ConnectorRequest (com.openshift.cloud.api.connector.models.ConnectorRequest)1