Search in sources :

Example 1 with ConnectorEntity

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

the class ConnectorsApiClientTest method testConnectorEntity.

private ConnectorEntity testConnectorEntity() {
    ConnectorEntity connectorEntity = new ConnectorEntity();
    connectorEntity.setType(ConnectorType.SINK);
    connectorEntity.setId(TEST_CONNECTOR_ID);
    connectorEntity.setName(TEST_CONNECTOR_NAME);
    connectorEntity.setConnectorTypeId(TEST_CONNECTOR_TYPE_ID);
    connectorEntity.setConnectorExternalId(TEST_CONNECTOR_EXTERNAL_ID);
    connectorEntity.setProcessor(testProcessor());
    return connectorEntity;
}
Also used : ConnectorEntity(com.redhat.service.smartevents.manager.models.ConnectorEntity)

Example 2 with ConnectorEntity

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

the class ConnectorsServiceTest method doCreateConnector.

@ParameterizedTest
@Transactional
@MethodSource("connectorProcessors")
void doCreateConnector(Processor processor, String expectedConnectorTypeId) {
    connectorsService.createConnectorEntity(processor);
    ArgumentCaptor<ConnectorEntity> captor = ArgumentCaptor.forClass(ConnectorEntity.class);
    verify(connectorsDAOMock).persist(captor.capture());
    ConnectorEntity entity = captor.getValue();
    assertThat(entity.getConnectorTypeId()).isEqualTo(expectedConnectorTypeId);
}
Also used : ConnectorEntity(com.redhat.service.smartevents.manager.models.ConnectorEntity) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) Transactional(javax.transaction.Transactional)

Example 3 with ConnectorEntity

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

the class ConnectorsDAOTest method findByProcessorIdName.

@Test
public void findByProcessorIdName() {
    Bridge b = createPersistBridge();
    Processor p = createPersistProcessor(b);
    ConnectorEntity c = createPersistConnector(p, ManagedResourceStatus.READY);
    assertThat(connectorsDAO.findByProcessorIdAndName(p.getId(), c.getName())).isEqualTo(c);
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) ConnectorEntity(com.redhat.service.smartevents.manager.models.ConnectorEntity) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 4 with ConnectorEntity

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

the class ConnectorsDAOTest method createPersistConnector.

private ConnectorEntity createPersistConnector(Processor p, ManagedResourceStatus status) {
    ConnectorEntity c = Fixtures.createSinkConnector(p, status);
    connectorsDAO.persist(c);
    return c;
}
Also used : ConnectorEntity(com.redhat.service.smartevents.manager.models.ConnectorEntity)

Example 5 with ConnectorEntity

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

the class ProcessorWorker method delegate.

private Processor delegate(Work work, Processor processor) {
    // Get Processor's Connector for which work needs completing
    final ConnectorEntity connectorEntity = getConnectorEntity(processor);
    // Delegate to the ConnectorWorker however mimic that the Work originated from the Processor.
    Work connectorEntityWork = Work.forDependentResource(connectorEntity, work);
    ConnectorEntity updatedConnectorEntity = connectorWorker.handleWork(connectorEntityWork);
    processor.setDependencyStatus(updatedConnectorEntity.getStatus());
    // If the Connector failed we should mark the Processor as failed too
    if (updatedConnectorEntity.getStatus() == ManagedResourceStatus.FAILED) {
        processor.setStatus(ManagedResourceStatus.FAILED);
    }
    return persist(processor);
}
Also used : ConnectorEntity(com.redhat.service.smartevents.manager.models.ConnectorEntity) Work(com.redhat.service.smartevents.manager.models.Work)

Aggregations

ConnectorEntity (com.redhat.service.smartevents.manager.models.ConnectorEntity)16 Processor (com.redhat.service.smartevents.manager.models.Processor)8 Bridge (com.redhat.service.smartevents.manager.models.Bridge)7 Transactional (javax.transaction.Transactional)6 Work (com.redhat.service.smartevents.manager.models.Work)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 MethodSource (org.junit.jupiter.params.provider.MethodSource)5 Connector (com.openshift.cloud.api.connector.models.Connector)3 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)3 QuarkusTest (io.quarkus.test.junit.QuarkusTest)3 Test (org.junit.jupiter.api.Test)3 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 Action (com.redhat.service.smartevents.infra.models.gateways.Action)1 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)1 SlackAction (com.redhat.service.smartevents.processor.actions.slack.SlackAction)1