Search in sources :

Example 31 with BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ConnectorsServiceTest method testKafkaAction.

private BaseAction testKafkaAction() {
    BaseAction action = new BaseAction();
    action.setType(KafkaTopicAction.TYPE);
    action.setParameters(Map.of(SlackAction.CHANNEL_PARAMETER, TEST_ACTION_CHANNEL, SlackAction.WEBHOOK_URL_PARAMETER, TEST_ACTION_WEBHOOK, KafkaTopicAction.TOPIC_PARAM, testActionTopic()));
    return action;
}
Also used : BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction)

Example 32 with BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ConnectorsDAOTest method createProcessor.

private Processor createProcessor(Bridge bridge, String name) {
    Processor p = new Processor();
    p.setBridge(bridge);
    p.setName(name);
    p.setStatus(ManagedResourceStatus.ACCEPTED);
    p.setSubmittedAt(ZonedDateTime.now());
    p.setPublishedAt(ZonedDateTime.now());
    BaseAction a = new BaseAction();
    a.setType(KafkaTopicAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
    a.setParameters(params);
    ProcessorDefinition definition = new ProcessorDefinition(Collections.emptySet(), null, a);
    p.setDefinition(mapper.valueToTree(definition));
    processorDAO.persist(p);
    return p;
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) HashMap(java.util.HashMap) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction)

Example 33 with BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class TestUtils method createSendToBridgeAction.

public static BaseAction createSendToBridgeAction(String bridgeId) {
    BaseAction r = new BaseAction();
    r.setType(SendToBridgeAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(SendToBridgeAction.BRIDGE_ID_PARAM, bridgeId);
    r.setParameters(params);
    return r;
}
Also used : HashMap(java.util.HashMap) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction)

Example 34 with BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ActionParamValidatorContainerTest method buildTestRequest.

private ProcessorRequest buildTestRequest() {
    ProcessorRequest p = new ProcessorRequest();
    BaseAction b = new BaseAction();
    b.setType(TEST_ACTION_TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(TEST_PARAM_NAME, TEST_PARAM_VALUE);
    b.setParameters(params);
    p.setAction(b);
    return p;
}
Also used : HashMap(java.util.HashMap) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Example 35 with BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class SendToBridgeActionTransformerTest method testActionWithUnavailableBridgeId.

@Test
void testActionWithUnavailableBridgeId() {
    BaseAction inputAction = actionWithBridgeId(UNAVAILABLE_BRIDGE_ID);
    ProcessorRequest inputRequest = requestWithAction(inputAction);
    assertThatExceptionOfType(BridgeLifecycleException.class).isThrownBy(() -> transformer.transform(inputRequest.getAction(), bridge.getId(), TEST_CUSTOMER_ID, ""));
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) BridgeLifecycleException(com.redhat.service.bridge.infra.exceptions.definitions.user.BridgeLifecycleException) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)48 Test (org.junit.jupiter.api.Test)20 QuarkusTest (io.quarkus.test.junit.QuarkusTest)15 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)13 HashMap (java.util.HashMap)13 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)10 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)10 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)9 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)9 Processor (com.redhat.service.bridge.manager.models.Processor)7 Bridge (com.redhat.service.bridge.manager.models.Bridge)6 HashSet (java.util.HashSet)6 CloudEvent (io.cloudevents.CloudEvent)5 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)4 ValidationResult (com.redhat.service.bridge.actions.ValidationResult)3 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)3 TestSecurity (io.quarkus.test.security.TestSecurity)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Connector (com.openshift.cloud.api.connector.models.Connector)2 ConnectorRequest (com.openshift.cloud.api.connector.models.ConnectorRequest)2