Search in sources :

Example 6 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method getProcessors.

@Test
public void getProcessors() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        Processor p = processorDAO.findById(processor.getId());
        assertThat(p).isNotNull();
        assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
    });
    ListResult<Processor> results = processorService.getProcessors(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(0, 100));
    assertThat(results.getPage()).isZero();
    assertThat(results.getSize()).isEqualTo(1L);
    assertThat(results.getTotal()).isEqualTo(1L);
    assertThat(results.getItems().get(0).getId()).isEqualTo(processor.getId());
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) QueryInfo(com.redhat.service.bridge.infra.models.QueryInfo) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 7 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method createProcessor.

@Test
public void createProcessor() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    ProcessorRequest r = new ProcessorRequest("My Processor", null, "{}", createKafkaAction());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        Processor p = processorDAO.findById(processor.getId());
        assertThat(p).isNotNull();
        assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
    });
    assertThat(processor.getBridge().getId()).isEqualTo(b.getId());
    assertThat(processor.getName()).isEqualTo(r.getName());
    assertThat(processor.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
    assertThat(processor.getSubmittedAt()).isNotNull();
    assertThat(processor.getDefinition()).isNotNull();
    ProcessorDefinition definition = jsonNodeToDefinition(processor.getDefinition());
    assertThat(definition.getTransformationTemplate()).isEqualTo("{}");
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 8 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method getProcessor_bridgeDoesNotExist.

@Test
public void getProcessor_bridgeDoesNotExist() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        Processor p = processorDAO.findById(processor.getId());
        assertThat(p).isNotNull();
        assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
    });
    assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> processorService.getProcessor(processor.getId(), "doesNotExist", b.getCustomerId()));
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.bridge.manager.models.Bridge) ItemNotFoundException(com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 9 with ProcessorRequest

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

Example 10 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest 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");
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) KafkaConnectionDTO(com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) List(java.util.List) ResponseLoggingFilter(io.restassured.filter.log.ResponseLoggingFilter) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)48 QuarkusTest (io.quarkus.test.junit.QuarkusTest)46 Test (org.junit.jupiter.api.Test)46 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)22 TestSecurity (io.quarkus.test.security.TestSecurity)22 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)17 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)16 Bridge (com.redhat.service.bridge.manager.models.Bridge)15 Processor (com.redhat.service.bridge.manager.models.Processor)14 Response (io.restassured.response.Response)14 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)9 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)8 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)8 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)5 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)5 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)5 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)5 List (java.util.List)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 ItemNotFoundException (com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException)3