Search in sources :

Example 16 with BridgeResponse

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

the class ProcessorAPITest method getProcessor.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessor() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", createKafkaAction()));
    assertThat(response.getStatusCode()).isEqualTo(201);
    ProcessorResponse pr = response.as(ProcessorResponse.class);
    assertThat(pr.getAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(pr.getAction().getParameters()).containsEntry(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
    ProcessorResponse found = TestUtils.getProcessor(bridgeResponse.getId(), pr.getId()).as(ProcessorResponse.class);
    assertThat(found.getId()).isEqualTo(pr.getId());
    assertThat(found.getAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(found.getAction().getParameters()).containsEntry(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
}
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 17 with BridgeResponse

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

the class ProcessorAPITest method addProcessorWithNullFiltersToBridge.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorWithNullFiltersToBridge() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", createKafkaAction()));
    assertThat(response.getStatusCode()).isEqualTo(201);
    ProcessorResponse processorResponse = response.as(ProcessorResponse.class);
    assertThat(processorResponse.getName()).isEqualTo("myProcessor");
    assertThat(processorResponse.getFilters()).isNull();
    assertThat(processorResponse.getTransformationTemplate()).isNull();
    assertRequestedAction(processorResponse);
}
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 18 with BridgeResponse

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

the class ShardBridgesSyncAPITest method testNotifyDeletion.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testNotifyDeletion() {
    TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
    List<BridgeDTO> bridgesToDeploy = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
    });
    BridgeDTO bridge = bridgesToDeploy.get(0);
    TestUtils.deleteBridge(bridge.getId()).then().statusCode(202);
    BridgeResponse bridgeResponse = TestUtils.getBridge(bridge.getId()).as(BridgeResponse.class);
    assertThat(bridgeResponse.getStatus()).isEqualTo(ManagedResourceStatus.DEPROVISION);
    bridge.setStatus(ManagedResourceStatus.DELETED);
    TestUtils.updateBridge(bridge).then().statusCode(200);
    TestUtils.getBridge(bridge.getId()).then().statusCode(404);
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) List(java.util.List) 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 19 with BridgeResponse

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

the class ShardBridgesSyncAPITest method getProcessorsWithSendToBridgeAction.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessorsWithSendToBridgeAction() {
    BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
    String bridgeId = bridgeResponse.getId();
    BridgeDTO bridge = new BridgeDTO(bridgeId, bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    BaseAction action = TestUtils.createSendToBridgeAction(bridgeId);
    TestUtils.updateBridge(bridge);
    TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, filters, null, action));
    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(SendToBridgeAction.TYPE);
    assertThat(processor.getDefinition().getRequestedAction().getParameters()).containsEntry(SendToBridgeAction.BRIDGE_ID_PARAM, bridgeId);
    assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
    assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(WebhookAction.TYPE);
    assertThat(processor.getDefinition().getResolvedAction().getParameters()).containsEntry(WebhookAction.ENDPOINT_PARAM, TEST_BRIDGE_WEBHOOK);
}
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) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) 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) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 20 with BridgeResponse

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

the class ShardBridgesSyncAPITest method updateProcessorStatus.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorStatus() {
    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);
    processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
    });
    assertThat(processors.size()).isZero();
}
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) TypeRef(io.restassured.common.mapper.TypeRef) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) List(java.util.List) 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

BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)30 QuarkusTest (io.quarkus.test.junit.QuarkusTest)24 TestSecurity (io.quarkus.test.security.TestSecurity)24 Test (org.junit.jupiter.api.Test)24 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)20 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)16 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)16 Response (io.restassured.response.Response)14 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)10 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)7 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)7 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)7 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)5 List (java.util.List)5 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)4 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)3 BridgeListResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeListResponse)3 ErrorResponse (com.redhat.service.bridge.infra.api.models.responses.ErrorResponse)1 ManagedResourceStatus (com.redhat.service.bridge.infra.models.dto.ManagedResourceStatus)1 ValuesIn (com.redhat.service.bridge.infra.models.filters.ValuesIn)1