Search in sources :

Example 26 with ProcessorDTO

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;
}
Also used : ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)

Example 27 with ProcessorDTO

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));
}
Also used : ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) ItemNotFoundException(com.redhat.service.smartevents.infra.exceptions.definitions.user.ItemNotFoundException) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with ProcessorDTO

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());
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 29 with ProcessorDTO

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);
}
Also used : BridgeDTO(com.redhat.service.smartevents.infra.models.dto.BridgeDTO) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 30 with ProcessorDTO

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);
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.smartevents.infra.models.dto.BridgeDTO) KafkaConnectionDTO(com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) TypeRef(io.restassured.common.mapper.TypeRef) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) ArrayList(java.util.ArrayList) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

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