Search in sources :

Example 1 with Processor

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

the class ConnectorsApiClientTest method testProcessor.

private Processor testProcessor() {
    Processor processor = new Processor();
    processor.setType(ProcessorType.SINK);
    processor.setId(TEST_PROCESSOR_ID);
    processor.setName(TEST_PROCESSOR_NAME);
    return processor;
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor)

Example 2 with Processor

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

the class ConnectorsServiceTest method processorWith.

private static Processor processorWith(Gateway gateway) {
    Processor processor = new Processor();
    processor.setBridge(new Bridge());
    ProcessorDefinition processorDefinition = new ProcessorDefinition();
    if (gateway instanceof Action) {
        processorDefinition.setRequestedAction((Action) gateway);
        processor.setType(ProcessorType.SINK);
    } else {
        processorDefinition.setRequestedSource((Source) gateway);
        processor.setType(ProcessorType.SOURCE);
    }
    processor.setId(TEST_PROCESSOR_ID);
    processor.setName(TEST_PROCESSOR_NAME);
    processor.setDefinition(processorDefinition);
    return processor;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) SlackAction(com.redhat.service.smartevents.processor.actions.slack.SlackAction) WebhookAction(com.redhat.service.smartevents.processor.actions.webhook.WebhookAction) Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorDefinition(com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition) Bridge(com.redhat.service.smartevents.manager.models.Bridge)

Example 3 with Processor

use of com.redhat.service.smartevents.manager.models.Processor 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 Processor

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

the class ConnectorsDAOTest method createPersistProcessor.

private Processor createPersistProcessor(Bridge bridge) {
    Processor p = Fixtures.createProcessor(bridge, ManagedResourceStatus.ACCEPTED);
    Action a = new Action();
    a.setType(KafkaTopicAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
    a.setMapParameters(params);
    ProcessorDefinition definition = new ProcessorDefinition(Collections.emptySet(), null, a);
    p.setDefinition(definition);
    processorDAO.persist(p);
    return p;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) Processor(com.redhat.service.smartevents.manager.models.Processor) HashMap(java.util.HashMap) ProcessorDefinition(com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)

Example 5 with Processor

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

the class BridgeWorker method createErrorHandlerProcessor.

/**
 * Creates error handler processor if required
 *
 * @param bridge input bridge
 * @return true if the work can proceed (either the error handler processor
 *         is not required or it's created and ready), false otherwise.
 */
private void createErrorHandlerProcessor(Bridge bridge) {
    // If an ErrorHandler is not needed, consider it ready
    Action errorHandlerAction = bridge.getDefinition().getErrorHandler();
    boolean errorHandlerProcessorIsNotRequired = Objects.isNull(errorHandlerAction);
    if (errorHandlerProcessorIsNotRequired) {
        return;
    }
    String bridgeId = bridge.getId();
    String customerId = bridge.getCustomerId();
    ListResult<Processor> processors = processorService.getHiddenProcessors(bridgeId, customerId);
    // This assumes we can only have one ErrorHandler Processor per Bridge
    if (processors.getTotal() > 0) {
        return;
    }
    // create error handler processor if not present
    String errorHandlerName = String.format("Back-channel for Bridge '%s'", bridge.getId());
    ProcessorRequest errorHandlerProcessor = new ProcessorRequest(errorHandlerName, errorHandlerAction);
    processorService.createErrorHandlerProcessor(bridge.getId(), bridge.getCustomerId(), bridge.getOwner(), errorHandlerProcessor);
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)

Aggregations

Processor (com.redhat.service.smartevents.manager.models.Processor)82 Bridge (com.redhat.service.smartevents.manager.models.Bridge)45 QuarkusTest (io.quarkus.test.junit.QuarkusTest)36 Test (org.junit.jupiter.api.Test)36 Transactional (javax.transaction.Transactional)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 Action (com.redhat.service.smartevents.infra.models.gateways.Action)13 QueryProcessorResourceInfo (com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo)12 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)9 MethodSource (org.junit.jupiter.params.provider.MethodSource)9 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)8 ConnectorEntity (com.redhat.service.smartevents.manager.models.ConnectorEntity)8 Connector (com.openshift.cloud.api.connector.models.Connector)7 Work (com.redhat.service.smartevents.manager.models.Work)7 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)6 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)6 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)6 InternalPlatformException (com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException)5 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)5 SlackAction (com.redhat.service.smartevents.processor.actions.slack.SlackAction)5