Search in sources :

Example 21 with Action

use of com.redhat.service.smartevents.infra.models.gateways.Action in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class KafkaTopicActionValidatorTest method isInvalid_nullParametersMapIsNotValid.

@Test
void isInvalid_nullParametersMapIsNotValid() {
    Action action = new Action();
    action.setType(KafkaTopicAction.TYPE);
    action.setMapParameters(new HashMap<>());
    ValidationResult validationResult = validator.isValid(action);
    assertThat(validationResult.isValid()).isFalse();
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) ValidationResult(com.redhat.service.smartevents.infra.validations.ValidationResult) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 22 with Action

use of com.redhat.service.smartevents.infra.models.gateways.Action in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class SlackActionResolver method resolve.

@Override
public Action resolve(Action action, String customerId, String bridgeId, String processorId) {
    Action resolvedAction = new Action();
    resolvedAction.setParameters(action.getParameters().deepCopy());
    resolvedAction.setType(KafkaTopicAction.TYPE);
    String connectorTopicName = gatewayConfiguratorService.getConnectorTopicName(processorId);
    resolvedAction.getParameters().set(KafkaTopicAction.TOPIC_PARAM, new TextNode(connectorTopicName));
    return resolvedAction;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) TextNode(com.fasterxml.jackson.databind.node.TextNode)

Example 23 with Action

use of com.redhat.service.smartevents.infra.models.gateways.Action in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorSteps method processorOfBridgeHasActionOfTypeAndParameters.

@And("^the Processor \"([^\"]*)\" of the Bridge \"([^\"]*)\" has action of type \"([^\"]*)\" and parameters:$")
public void processorOfBridgeHasActionOfTypeAndParameters(String processorName, String testBridgeName, String actionType, DataTable parametersDatatable) {
    Action action = getProcessorAction(processorName, testBridgeName);
    assertThat(action.getType()).isEqualTo(actionType);
    parametersDatatable.asMap().forEach((key, value) -> {
        String parameterTextWithoutPlaceholders = ContextResolver.resolveWithScenarioContext(context, value);
        assertThat(action.getParameter(key)).isEqualTo(parameterTextWithoutPlaceholders);
    });
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) And(io.cucumber.java.en.And)

Example 24 with Action

use of com.redhat.service.smartevents.infra.models.gateways.Action in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesServiceImpl method createBridge.

@Override
@Transactional
public Bridge createBridge(String customerId, String organisationId, String owner, BridgeRequest bridgeRequest) {
    if (bridgeDAO.findByNameAndCustomerId(bridgeRequest.getName(), customerId) != null) {
        throw new AlreadyExistingItemException(String.format("Bridge with name '%s' already exists for customer with id '%s'", bridgeRequest.getName(), customerId));
    }
    Bridge bridge = bridgeRequest.toEntity();
    bridge.setStatus(ManagedResourceStatus.ACCEPTED);
    bridge.setSubmittedAt(ZonedDateTime.now(ZoneOffset.UTC));
    bridge.setCustomerId(customerId);
    bridge.setOrganisationId(organisationId);
    bridge.setOwner(owner);
    bridge.setShardId(shardService.getAssignedShardId(bridge.getId()));
    // Ensure we connect the ErrorHandler Action to the ErrorHandler back-channel
    Action errorHandler = bridgeRequest.getErrorHandler();
    bridge.setDefinition(new BridgeDefinition(Objects.nonNull(errorHandler) ? errorHandler : null));
    // Bridge and Work creation should always be in the same transaction
    bridgeDAO.persist(bridge);
    workManager.schedule(bridge);
    metricsService.onOperationStart(bridge, MetricsOperation.PROVISION);
    LOGGER.info("Bridge with id '{}' has been created for customer '{}'", bridge.getId(), bridge.getCustomerId());
    return bridge;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) BridgeDefinition(com.redhat.service.smartevents.infra.models.bridges.BridgeDefinition) Bridge(com.redhat.service.smartevents.manager.models.Bridge) AlreadyExistingItemException(com.redhat.service.smartevents.infra.exceptions.definitions.user.AlreadyExistingItemException) Transactional(javax.transaction.Transactional)

Example 25 with Action

use of com.redhat.service.smartevents.infra.models.gateways.Action in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class SendToBridgeActionResolverTest method actionWithBridgeId.

private Action actionWithBridgeId(String bridgeId) {
    Action action = actionWithoutBridgeId();
    action.setMapParameters(Map.of(SendToBridgeAction.BRIDGE_ID_PARAM, bridgeId));
    return action;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) WebhookAction(com.redhat.service.smartevents.processor.actions.webhook.WebhookAction)

Aggregations

Action (com.redhat.service.smartevents.infra.models.gateways.Action)62 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)23 QuarkusTest (io.quarkus.test.junit.QuarkusTest)23 Test (org.junit.jupiter.api.Test)23 WebhookAction (com.redhat.service.smartevents.processor.actions.webhook.WebhookAction)21 SlackAction (com.redhat.service.smartevents.processor.actions.slack.SlackAction)13 HashMap (java.util.HashMap)13 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)12 Processor (com.redhat.service.smartevents.manager.models.Processor)12 SendToBridgeAction (com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)12 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)9 Source (com.redhat.service.smartevents.infra.models.gateways.Source)7 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)6 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)6 Bridge (com.redhat.service.smartevents.manager.models.Bridge)6 TestSecurity (io.quarkus.test.security.TestSecurity)6 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)5 Response (io.restassured.response.Response)5 ProcessorDTO (com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)4 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)4