Search in sources :

Example 6 with BaseFilter

use of com.redhat.service.bridge.infra.models.filters.BaseFilter 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 7 with BaseFilter

use of com.redhat.service.bridge.infra.models.filters.BaseFilter in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method addProcessorToBridge_noActionSpecified.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridge_noActionSpecified() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, null, null));
    assertThat(response.getStatusCode()).isEqualTo(400);
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) 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) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) 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 8 with BaseFilter

use of com.redhat.service.bridge.infra.models.filters.BaseFilter in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method addProcessorToBridge.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridge() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, "{}", createKafkaAction()));
    assertThat(response.getStatusCode()).isEqualTo(201);
    ProcessorResponse processorResponse = response.as(ProcessorResponse.class);
    assertThat(processorResponse.getName()).isEqualTo("myProcessor");
    assertThat(processorResponse.getFilters().size()).isEqualTo(1);
    ProcessorResponse retrieved = TestUtils.getProcessor(bridgeResponse.getId(), processorResponse.getId()).as(ProcessorResponse.class);
    assertThat(retrieved.getName()).isEqualTo("myProcessor");
    assertThat(retrieved.getFilters().size()).isEqualTo(1);
    assertThat(retrieved.getTransformationTemplate()).isEqualTo("{}");
    assertRequestedAction(retrieved);
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) 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) 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 9 with BaseFilter

use of com.redhat.service.bridge.infra.models.filters.BaseFilter in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method addProcessorToBridge_missingActionParameters.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridge_missingActionParameters() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    BaseAction action = createKafkaAction();
    action.getParameters().clear();
    action.getParameters().put("thisIsNotCorrect", "myTopic");
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, null, action));
    assertThat(response.getStatusCode()).isEqualTo(400);
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) 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) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) 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 BaseFilter

use of com.redhat.service.bridge.infra.models.filters.BaseFilter 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}}";
    BaseAction a = new BaseAction();
    a.setType(KafkaTopicAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(KafkaTopicAction.TOPIC_PARAM, "myTopic");
    a.setParameters(params);
    ProcessorDefinition definition = new ProcessorDefinition(filters, transformationTemplate, a);
    return new ProcessorDTO(PROCESSOR_ID, PROCESSOR_NAME, definition, BRIDGE_ID, CUSTOMER_ID, ManagedResourceStatus.ACCEPTED, KAFKA_CONNECTION_DTO);
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) HashMap(java.util.HashMap) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) HashSet(java.util.HashSet)

Aggregations

BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)15 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)14 Test (org.junit.jupiter.api.Test)13 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)10 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)8 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)8 QuarkusTest (io.quarkus.test.junit.QuarkusTest)8 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)7 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)7 TestSecurity (io.quarkus.test.security.TestSecurity)7 HashSet (java.util.HashSet)7 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)5 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)5 CloudEvent (io.cloudevents.CloudEvent)5 Response (io.restassured.response.Response)5 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)2 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)2 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)2 Bridge (com.redhat.service.bridge.manager.models.Bridge)2 Processor (com.redhat.service.bridge.manager.models.Processor)2