use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ConnectorsServiceTest method slackSource.
private static Source slackSource() {
Source action = new Source();
action.setType(SlackSource.TYPE);
action.setMapParameters(Map.of(SlackSource.CHANNEL_PARAM, TEST_SOURCE_CHANNEL, SlackSource.TOKEN_PARAM, TEST_SOURCE_TOKEN));
return action;
}
use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method createSlackSource.
private static Source createSlackSource() {
Source source = new Source();
source.setType(SlackSource.TYPE);
source.setMapParameters(Map.of(SlackSource.CHANNEL_PARAM, "test-channel", SlackSource.TOKEN_PARAM, "test-token"));
return source;
}
use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testUpdateProcessorWithGatewayWithOppositeType.
@ParameterizedTest
@MethodSource("updateProcessorParams")
void testUpdateProcessorWithGatewayWithOppositeType(ProcessorRequest request) {
Processor existingProcessor = createReadyProcessorFromRequest(request);
when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(existingProcessor);
if (request.getType() == ProcessorType.SOURCE) {
Action dummyNewAction = new Action();
dummyNewAction.setType("DummyAction");
request.setAction(dummyNewAction);
request.setSource(null);
} else if (request.getType() == SINK) {
Source dummyNewSource = new Source();
dummyNewSource.setType("DummySource");
request.setSource(dummyNewSource);
request.setAction(null);
}
assertThatExceptionOfType(BadRequestException.class).isThrownBy(() -> processorService.updateProcessor(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID, request));
}
use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class TestUtils method createSlackSource.
public static Source createSlackSource() {
Source s = new Source();
s.setType(SlackSource.TYPE);
Map<String, String> params = new HashMap<>();
params.put(SlackSource.CHANNEL_PARAM, "channel");
params.put(SlackSource.TOKEN_PARAM, "token");
s.setMapParameters(params);
return s;
}
use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class GatewayConnectorTest method testSlackConnectorPayloadWithErrorHandler.
@Test
public void testSlackConnectorPayloadWithErrorHandler() throws JsonProcessingException {
String channel = "channel";
String token = "token";
String topicName = "topic";
String errorTopicName = "errorHandlerTopic";
String payload = "{" + " \"slack_channel\":\"" + channel + "\"," + " \"slack_token\":\"" + token + "\"," + " \"kafka_topic\":\"" + topicName + "\"," + " \"processors\": [" + " {" + " \"log\": {" + " \"multiLine\":true," + " \"showHeaders\":true" + " }" + " }" + " ], " + " \"error_handler\": {" + " \"dead_letter_queue\": {" + " \"topic\": \"errorHandlerTopic\"" + " }" + " }" + "}";
JsonNode expectedPayload = mapper.readTree(payload);
Source source = new Source();
source.setType(SlackSource.TYPE);
source.setMapParameters(Map.of(SlackSource.CHANNEL_PARAM, channel, SlackSource.TOKEN_PARAM, token));
JsonNode actualPayload = gatewayConnector.connectorPayload(source, topicName, errorTopicName);
assertThat(actualPayload).isEqualTo(expectedPayload);
}
Aggregations