use of com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method getProcessorsWithSendToBridgeAction.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void getProcessorsWithSendToBridgeAction() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
String bridgeId = bridgeResponse.getId();
// Emulate the Shard having deployed the Bridge
BridgeDTO bridge = new BridgeDTO(bridgeId, bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, DEFAULT_CUSTOMER_ID, DEFAULT_USER_NAME, READY, new KafkaConnectionDTO());
TestUtils.updateBridge(bridge);
// Create a Processor for the Bridge
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
Action action = TestUtils.createSendToBridgeAction(bridgeId);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(DEFAULT_PROCESSOR_NAME, filters, null, action));
final List<ProcessorDTO> processors = new ArrayList<>();
await().atMost(5, SECONDS).untilAsserted(() -> {
processors.clear();
processors.addAll(TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
}));
assertThat(processors.size()).isEqualTo(1);
});
ProcessorDTO processor = processors.get(0);
assertThat(processor.getName()).isEqualTo(DEFAULT_PROCESSOR_NAME);
assertThat(processor.getStatus()).isEqualTo(PREPARING);
assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
assertThat(processor.getDefinition().getRequestedAction().getParameter(SendToBridgeAction.BRIDGE_ID_PARAM)).isEqualTo(bridgeId);
assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(WebhookAction.TYPE);
assertThat(processor.getDefinition().getResolvedAction().getParameter(WebhookAction.ENDPOINT_PARAM)).isEqualTo(TEST_BRIDGE_WEBHOOK);
}
use of com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method metricsAreProduced.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void metricsAreProduced() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, DEFAULT_CUSTOMER_ID, DEFAULT_USER_NAME, READY, new KafkaConnectionDTO());
TestUtils.updateBridge(bridge);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(DEFAULT_PROCESSOR_NAME, TestUtils.createKafkaAction()));
final List<ProcessorDTO> processors = new ArrayList<>();
await().atMost(5, SECONDS).untilAsserted(() -> {
processors.clear();
processors.addAll(TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
}));
assertThat(processors.size()).isEqualTo(1);
});
ProcessorDTO processor = processors.get(0);
processor.setStatus(READY);
TestUtils.updateProcessor(processor);
String metrics = given().filter(new ResponseLoggingFilter()).contentType(ContentType.JSON).when().get("/q/metrics").then().extract().body().asString();
metricsService.getMetricNames().forEach(metric -> assertThat(metrics).contains(metric));
}
use of com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesAPITest method testDeleteBridgeWithActiveProcessors.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testDeleteBridgeWithActiveProcessors() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
TestUtils.updateBridge(new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), bridgeResponse.getEndpoint(), DEFAULT_CUSTOMER_ID, DEFAULT_USER_NAME, READY, new KafkaConnectionDTO()));
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(DEFAULT_PROCESSOR_NAME, TestUtils.createKafkaAction())).then().statusCode(202);
TestUtils.deleteBridge(bridgeResponse.getId()).then().statusCode(400);
}
use of com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceImpl method toDTO.
@Override
public BridgeDTO toDTO(Bridge bridge) {
KafkaConnectionDTO kafkaConnectionDTO = new KafkaConnectionDTO(internalKafkaConfigurationProvider.getBootstrapServers(), internalKafkaConfigurationProvider.getClientId(), internalKafkaConfigurationProvider.getClientSecret(), internalKafkaConfigurationProvider.getSecurityProtocol(), resourceNamesProvider.getBridgeTopicName(bridge.getId()), resourceNamesProvider.getBridgeErrorTopicName(bridge.getId()));
BridgeDTO dto = new BridgeDTO();
dto.setId(bridge.getId());
dto.setName(bridge.getName());
dto.setEndpoint(bridge.getEndpoint());
dto.setStatus(bridge.getStatus());
dto.setCustomerId(bridge.getCustomerId());
dto.setOwner(bridge.getOwner());
dto.setKafkaConnection(kafkaConnectionDTO);
return dto;
}
use of com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method getProcessorsWithKafkaAction.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void getProcessorsWithKafkaAction() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
// Emulate the Shard having deployed the Bridge
BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, DEFAULT_CUSTOMER_ID, DEFAULT_USER_NAME, READY, new KafkaConnectionDTO());
TestUtils.updateBridge(bridge);
// Create a Processor for the Bridge
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(DEFAULT_PROCESSOR_NAME, filters, null, TestUtils.createKafkaAction()));
final List<ProcessorDTO> processors = new ArrayList<>();
await().atMost(5, SECONDS).untilAsserted(() -> {
processors.clear();
processors.addAll(TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
}));
assertThat(processors.size()).isEqualTo(1);
});
ProcessorDTO processor = processors.get(0);
assertThat(processor.getName()).isEqualTo(DEFAULT_PROCESSOR_NAME);
assertThat(processor.getStatus()).isEqualTo(PREPARING);
assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
assertThat(processor.getDefinition().getRequestedAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
assertThat(processor.getDefinition().getResolvedAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
}
Aggregations