use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method toDTO.
@Override
public ProcessorDTO toDTO(Processor processor) {
ProcessorDTO dto = new ProcessorDTO();
dto.setType(processor.getType());
dto.setId(processor.getId());
dto.setName(processor.getName());
dto.setDefinition(processor.getDefinition());
dto.setBridgeId(processor.getBridge().getId());
dto.setCustomerId(processor.getBridge().getCustomerId());
dto.setOwner(processor.getOwner());
dto.setStatus(processor.getStatus());
dto.setKafkaConnection(getKafkaConnectorDTO(processor));
return dto;
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testUpdateProcessorStatus_bridgeDoesNotExist.
@Test
void testUpdateProcessorStatus_bridgeDoesNotExist() {
ProcessorDTO processor = new ProcessorDTO();
processor.setBridgeId(NON_EXISTING_BRIDGE_ID);
assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> processorService.updateProcessorStatus(processor));
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testUpdateProcessorStatusReadyPublishedAt.
@Test
void testUpdateProcessorStatusReadyPublishedAt() {
ProcessorDTO updateDto = new ProcessorDTO();
updateDto.setType(DEFAULT_PROCESSOR_TYPE);
updateDto.setId(DEFAULT_PROCESSOR_ID);
updateDto.setBridgeId(DEFAULT_BRIDGE_ID);
updateDto.setCustomerId(DEFAULT_CUSTOMER_ID);
updateDto.setStatus(READY);
Processor publishedProcessor = processorService.updateProcessorStatus(updateDto);
assertThat(publishedProcessor.getStatus()).isEqualTo(READY);
assertThat(publishedProcessor.getPublishedAt()).isNotNull();
// Check calls to set PublishedAt at idempotent
Processor publishedProcessor2 = processorService.updateProcessorStatus(updateDto);
assertThat(publishedProcessor2.getStatus()).isEqualTo(READY);
assertThat(publishedProcessor2.getPublishedAt()).isEqualTo(publishedProcessor.getPublishedAt());
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method testUnauthorizedRole.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testUnauthorizedRole() {
reset(jwt);
when(jwt.getClaim(ACCOUNT_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM)).thenReturn("hacker");
when(jwt.containsClaim(ACCOUNT_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM)).thenReturn(true);
TestUtils.getBridgesToDeployOrDelete().then().statusCode(403);
TestUtils.getProcessorsToDeployOrDelete().then().statusCode(403);
TestUtils.updateBridge(new BridgeDTO()).then().statusCode(403);
TestUtils.updateProcessor(new ProcessorDTO()).then().statusCode(403);
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO 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