Search in sources :

Example 11 with ProcessorResponse

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

the class ProcessorAPITest method getProcessor_bridgeDoesNotExist.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessor_bridgeDoesNotExist() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    ProcessorResponse response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", createKafkaAction())).as(ProcessorResponse.class);
    Response found = TestUtils.getProcessor("doesNotExist", response.getId());
    assertThat(found.getStatusCode()).isEqualTo(404);
}
Also used : ProcessorListResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) ProcessorResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse) Response(io.restassured.response.Response) ProcessorResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) 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)

Example 12 with ProcessorResponse

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

the class ProcessorSteps method addProcessorToBridgeWithBody.

@When("^add a Processor to the Bridge \"([^\"]*)\" with body:$")
public void addProcessorToBridgeWithBody(String testBridgeName, String processorRequestJson) {
    BridgeContext bridgeContext = context.getBridge(testBridgeName);
    JsonObject json = new JsonObject(processorRequestJson);
    String processorName = json.getString("name");
    ProcessorResponse response;
    try (InputStream resourceStream = new ByteArrayInputStream(processorRequestJson.getBytes(StandardCharsets.UTF_8))) {
        response = ProcessorResource.createProcessor(context.getManagerToken(), bridgeContext.getId(), resourceStream);
    } catch (IOException e) {
        throw new RuntimeException("Error with inputstream", e);
    }
    bridgeContext.newProcessor(processorName, response.getId());
    assertThat(response.getName()).isEqualTo(processorName);
    assertThat(response.getKind()).isEqualTo("Processor");
    assertThat(response.getHref()).isNotNull();
    assertThat(response.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
}
Also used : ProcessorResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BridgeContext(com.redhat.service.bridge.integration.tests.context.BridgeContext) JsonObject(io.vertx.core.json.JsonObject) IOException(java.io.IOException) When(io.cucumber.java.en.When)

Example 13 with ProcessorResponse

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

the class ProcessorServiceImpl method toResponse.

@Override
public ProcessorResponse toResponse(Processor processor) {
    ProcessorResponse processorResponse = new ProcessorResponse();
    processorResponse.setId(processor.getId());
    processorResponse.setName(processor.getName());
    processorResponse.setStatus(processor.getStatus());
    processorResponse.setPublishedAt(processor.getPublishedAt());
    processorResponse.setSubmittedAt(processor.getSubmittedAt());
    if (processor.getDefinition() != null) {
        ProcessorDefinition definition = jsonNodeToDefinition(processor.getDefinition());
        processorResponse.setFilters(definition.getFilters());
        processorResponse.setTransformationTemplate(definition.getTransformationTemplate());
        processorResponse.setAction(definition.getRequestedAction());
    }
    if (processor.getBridge() != null) {
        processorResponse.setHref(APIConstants.USER_API_BASE_PATH + processor.getBridge().getId() + "/processors/" + processor.getId());
    }
    return processorResponse;
}
Also used : ProcessorResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)

Aggregations

ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)13 QuarkusTest (io.quarkus.test.junit.QuarkusTest)10 Test (org.junit.jupiter.api.Test)10 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)9 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)9 TestSecurity (io.quarkus.test.security.TestSecurity)9 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)8 Response (io.restassured.response.Response)6 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)2 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)2 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)2 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)2 BridgeContext (com.redhat.service.bridge.integration.tests.context.BridgeContext)2 Bridge (com.redhat.service.bridge.manager.models.Bridge)1 Processor (com.redhat.service.bridge.manager.models.Processor)1 And (io.cucumber.java.en.And)1 When (io.cucumber.java.en.When)1 JsonObject (io.vertx.core.json.JsonObject)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1