use of com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method toDTO.
@Override
public ProcessorDTO toDTO(Processor processor) {
ProcessorDefinition definition = processor.getDefinition() != null ? jsonNodeToDefinition(processor.getDefinition()) : null;
KafkaConnectionDTO kafkaConnectionDTO = new KafkaConnectionDTO(internalKafkaConfigurationProvider.getBootstrapServers(), internalKafkaConfigurationProvider.getClientId(), internalKafkaConfigurationProvider.getClientSecret(), internalKafkaConfigurationProvider.getSecurityProtocol(), bridgesService.getBridgeTopicName(processor.getBridge()));
return new ProcessorDTO(processor.getId(), processor.getName(), definition, processor.getBridge().getId(), processor.getBridge().getCustomerId(), processor.getStatus(), kafkaConnectionDTO);
}
use of com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method getProcessorsWithKafkaAction.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessorsWithKafkaAction() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
TestUtils.updateBridge(bridge);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, filters, null, TestUtils.createKafkaAction()));
List<ProcessorDTO> processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
});
assertThat(processors.size()).isEqualTo(1);
ProcessorDTO processor = processors.get(0);
assertThat(processor.getName()).isEqualTo(TestConstants.DEFAULT_PROCESSOR_NAME);
assertThat(processor.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
assertThat(processor.getDefinition().getRequestedAction().getParameters()).containsEntry(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
assertThat(processor.getDefinition().getResolvedAction().getParameters()).containsEntry(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
}
use of com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method metricsAreProduced.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void metricsAreProduced() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
TestUtils.updateBridge(bridge);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, TestUtils.createKafkaAction()));
List<ProcessorDTO> processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
});
ProcessorDTO processor = processors.get(0);
processor.setStatus(ManagedResourceStatus.READY);
TestUtils.updateProcessor(processor);
String metrics = given().filter(new ResponseLoggingFilter()).contentType(ContentType.JSON).when().get("/q/metrics").then().extract().body().asString();
assertThat(metrics).contains("manager_processor_status_change_total");
assertThat(metrics).contains("manager_bridge_status_change_total");
}
use of com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesAPITest method testDeleteBridgeWithActiveProcessors.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testDeleteBridgeWithActiveProcessors() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
TestUtils.updateBridge(new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), bridgeResponse.getEndpoint(), TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO()));
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, TestUtils.createKafkaAction())).then().statusCode(201);
TestUtils.deleteBridge(bridgeResponse.getId()).then().statusCode(400);
}
use of com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method getProcessorsWithSendToBridgeAction.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessorsWithSendToBridgeAction() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
String bridgeId = bridgeResponse.getId();
BridgeDTO bridge = new BridgeDTO(bridgeId, bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
BaseAction action = TestUtils.createSendToBridgeAction(bridgeId);
TestUtils.updateBridge(bridge);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, filters, null, action));
List<ProcessorDTO> processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
});
assertThat(processors.size()).isEqualTo(1);
ProcessorDTO processor = processors.get(0);
assertThat(processor.getName()).isEqualTo(TestConstants.DEFAULT_PROCESSOR_NAME);
assertThat(processor.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
assertThat(processor.getDefinition().getRequestedAction().getParameters()).containsEntry(SendToBridgeAction.BRIDGE_ID_PARAM, bridgeId);
assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(WebhookAction.TYPE);
assertThat(processor.getDefinition().getResolvedAction().getParameters()).containsEntry(WebhookAction.ENDPOINT_PARAM, TEST_BRIDGE_WEBHOOK);
}
Aggregations