Search in sources :

Example 16 with ConnectorEntity

use of com.redhat.service.bridge.manager.models.ConnectorEntity in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method waitForConnectorToBeDeleted.

private void waitForConnectorToBeDeleted(final Bridge bridge, final Processor processor) {
    // There will be 2 re-tries at 5s each. Add 5s to be certain everything completes.
    await().atMost(15, SECONDS).untilAsserted(() -> {
        ConnectorEntity foundConnector = connectorsDAO.findByProcessorIdAndName(processor.getId(), "connectorToBeDeleted");
        assertThat(foundConnector).isNull();
        final Processor processorDeleted = processorService.getProcessor(processor.getId(), bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
        assertThat(processorDeleted.getStatus()).isEqualTo(DEPROVISION);
    });
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ConnectorEntity(com.redhat.service.bridge.manager.models.ConnectorEntity)

Example 17 with ConnectorEntity

use of com.redhat.service.bridge.manager.models.ConnectorEntity in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ConnectorsServiceImpl method createConnectorEntity.

@Override
@Transactional(Transactional.TxType.MANDATORY)
public // Connector should always be marked for creation in the same transaction as a Processor
void createConnectorEntity(BaseAction resolvedAction, Processor processor, ActionProvider actionProvider) {
    if (!actionProvider.isConnectorAction()) {
        return;
    }
    ConnectorAction connectorAction = (ConnectorAction) actionProvider;
    JsonNode connectorPayload = connectorAction.connectorPayload(resolvedAction);
    String connectorType = connectorAction.getConnectorType();
    String newConnectorName = connectorName(connectorType, processor);
    String topicName = connectorAction.topicName(resolvedAction);
    ConnectorEntity newConnectorEntity = new ConnectorEntity();
    newConnectorEntity.setName(newConnectorName);
    newConnectorEntity.setStatus(ManagedResourceStatus.ACCEPTED);
    newConnectorEntity.setSubmittedAt(ZonedDateTime.now());
    newConnectorEntity.setProcessor(processor);
    newConnectorEntity.setDefinition(connectorPayload);
    newConnectorEntity.setConnectorType(connectorType);
    newConnectorEntity.setTopicName(topicName);
    connectorsDAO.persist(newConnectorEntity);
}
Also used : ConnectorEntity(com.redhat.service.bridge.manager.models.ConnectorEntity) ConnectorAction(com.redhat.service.bridge.manager.actions.connectors.ConnectorAction) JsonNode(com.fasterxml.jackson.databind.JsonNode) Transactional(javax.transaction.Transactional)

Aggregations

ConnectorEntity (com.redhat.service.bridge.manager.models.ConnectorEntity)17 Processor (com.redhat.service.bridge.manager.models.Processor)9 Connector (com.openshift.cloud.api.connector.models.Connector)6 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)6 Bridge (com.redhat.service.bridge.manager.models.Bridge)6 QuarkusTest (io.quarkus.test.junit.QuarkusTest)6 Test (org.junit.jupiter.api.Test)6 Work (com.redhat.service.bridge.manager.models.Work)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ZonedDateTime (java.time.ZonedDateTime)3 InternalPlatformException (com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException)2 Transactional (javax.transaction.Transactional)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 ConnectorRequest (com.openshift.cloud.api.connector.models.ConnectorRequest)1 Topic (com.openshift.cloud.api.kas.auth.models.Topic)1 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)1 ConnectorAction (com.redhat.service.bridge.manager.actions.connectors.ConnectorAction)1