Search in sources :

Example 21 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class TestSupport method newRequestedProcessorDTO.

public static ProcessorDTO newRequestedProcessorDTO() {
    Set<BaseFilter> filters = new HashSet<>();
    filters.add(new StringEquals("key", "value"));
    String transformationTemplate = "{\"test\": {key}}";
    Action a = new Action();
    a.setType(KafkaTopicAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(KafkaTopicAction.TOPIC_PARAM, "myTopic");
    a.setMapParameters(params);
    ProcessorDefinition definition = new ProcessorDefinition(filters, transformationTemplate, a);
    ProcessorDTO dto = new ProcessorDTO();
    dto.setType(PROCESSOR_TYPE);
    dto.setId(PROCESSOR_ID);
    dto.setName(PROCESSOR_NAME);
    dto.setDefinition(definition);
    dto.setBridgeId(BRIDGE_ID);
    dto.setCustomerId(CUSTOMER_ID);
    dto.setOwner(USER_NAME);
    dto.setStatus(PREPARING);
    dto.setKafkaConnection(KAFKA_CONNECTION_DTO);
    return dto;
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) HashMap(java.util.HashMap) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) HashSet(java.util.HashSet)

Example 22 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorServiceTest method testBridgeIngressDeletion.

@Test
public void testBridgeIngressDeletion() {
    // Given
    ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
    // When
    bridgeExecutorService.createBridgeExecutor(dto);
    bridgeExecutorService.deleteBridgeExecutor(dto);
    // Then
    BridgeExecutor bridgeExecutor = kubernetesClient.resources(BridgeExecutor.class).inNamespace(customerNamespaceProvider.resolveName(dto.getCustomerId())).withName(BridgeExecutor.resolveResourceName(dto.getId())).get();
    assertThat(bridgeExecutor).isNull();
}
Also used : ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) BridgeExecutor(com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 23 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ManagerClientTest method fetchProcessorsToDeployOrDelete.

@Test
public void fetchProcessorsToDeployOrDelete() throws JsonProcessingException {
    ProcessorDTO processor = TestSupport.newRequestedProcessorDTO();
    stubProcessorsToDeployOrDelete(List.of(processor));
    assertThat(managerClient.fetchProcessorsToDeployOrDelete().await().atMost(Duration.ofSeconds(10)).size()).isEqualTo(1);
}
Also used : ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 24 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorController method notifyManager.

private void notifyManager(BridgeExecutor bridgeExecutor, ManagedResourceStatus status) {
    ProcessorDTO dto = bridgeExecutor.toDTO();
    dto.setStatus(status);
    managerClient.notifyProcessorStatusChange(dto).subscribe().with(success -> LOGGER.info("Updating Processor with id '{}' done", dto.getId()), failure -> LOGGER.error("Updating Processor with id '{}' FAILED", dto.getId()));
}
Also used : ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)

Example 25 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutor method toDTO.

public ProcessorDTO toDTO() {
    ProcessorDTO processorDTO = new ProcessorDTO();
    processorDTO.setType(ProcessorType.fromString(this.getSpec().getProcessorType()));
    processorDTO.setId(this.getSpec().getId());
    // TODO: think about removing bridgeDTO from the processorDTO and keep only bridgeId and customerId!
    processorDTO.setBridgeId(this.getSpec().getBridgeId());
    processorDTO.setCustomerId(this.getSpec().getCustomerId());
    processorDTO.setOwner(this.getSpec().getOwner());
    processorDTO.setName(this.getSpec().getProcessorName());
    if (this.getSpec().getProcessorDefinition() != null) {
        try {
            processorDTO.setDefinition(MAPPER.readValue(this.getSpec().getProcessorDefinition(), ProcessorDefinition.class));
        } catch (JsonProcessingException e) {
            LOGGER.error("Could not deserialize Processor Definition while converting BridgeExecutor to ProcessorDTO", e);
        }
    }
    return processorDTO;
}
Also used : ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

ProcessorDTO (com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)33 Test (org.junit.jupiter.api.Test)24 QuarkusTest (io.quarkus.test.junit.QuarkusTest)22 BridgeDTO (com.redhat.service.smartevents.infra.models.dto.BridgeDTO)5 TestSecurity (io.quarkus.test.security.TestSecurity)5 KafkaConnectionDTO (com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO)4 Action (com.redhat.service.smartevents.infra.models.gateways.Action)4 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)4 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)4 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)4 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)4 ActionInvoker (com.redhat.service.smartevents.processor.actions.ActionInvoker)4 TypeRef (io.restassured.common.mapper.TypeRef)4 ArrayList (java.util.ArrayList)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)3 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)3 HashMap (java.util.HashMap)3 ItemNotFoundException (com.redhat.service.smartevents.infra.exceptions.definitions.user.ItemNotFoundException)2