Search in sources :

Example 26 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ShardBridgesSyncAPITest method testUnouthorizedRole.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testUnouthorizedRole() {
    reset(jwt);
    when(jwt.getClaim(APIConstants.SUBJECT_ATTRIBUTE_CLAIM)).thenReturn("hacker");
    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.bridge.infra.models.dto.BridgeDTO) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 27 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO 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)

Example 28 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorController method notifyManager.

private void notifyManager(BridgeExecutor bridgeExecutor, ManagedResourceStatus status) {
    ProcessorDTO dto = bridgeExecutor.toDTO();
    dto.setStatus(status);
    managerSyncService.notifyProcessorStatusChange(dto).subscribe().with(success -> LOGGER.info("Updating Processor with id '{}' done", dto.getId()), failure -> LOGGER.error("Updating Processor with id '{}' FAILED", dto.getId()));
}
Also used : ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO)

Example 29 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class KafkaTopicActionTest method getActionInvoker_requestedTopicDoesNotExist.

@Test
public void getActionInvoker_requestedTopicDoesNotExist() {
    ProcessorDTO p = createProcessorWithActionForTopic("thisTopicDoesNotExist");
    assertThatExceptionOfType(ActionProviderException.class).isThrownBy(() -> kafkaTopicAction.getActionInvoker(p, p.getDefinition().getResolvedAction()));
    verify(kafkaAdmin).listTopics();
}
Also used : ActionProviderException(com.redhat.service.bridge.infra.exceptions.definitions.user.ActionProviderException) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 30 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class KafkaTopicActionTest method getActionInvoker.

@Test
public void getActionInvoker() {
    ProcessorDTO p = createProcessorWithActionForTopic(TOPIC_NAME);
    ActionInvoker actionInvoker = kafkaTopicAction.getActionInvoker(p, p.getDefinition().getResolvedAction());
    assertThat(actionInvoker).isNotNull();
    verify(kafkaAdmin).listTopics();
}
Also used : ActionInvoker(com.redhat.service.bridge.actions.ActionInvoker) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)39 Test (org.junit.jupiter.api.Test)28 QuarkusTest (io.quarkus.test.junit.QuarkusTest)21 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)11 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)10 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)6 HashSet (java.util.HashSet)6 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)5 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)5 CloudEvent (io.cloudevents.CloudEvent)5 TestSecurity (io.quarkus.test.security.TestSecurity)5 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)4 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)4 HashMap (java.util.HashMap)4 List (java.util.List)4 ActionInvoker (com.redhat.service.bridge.actions.ActionInvoker)2 ValidationResult (com.redhat.service.bridge.actions.ValidationResult)2 ActionProviderException (com.redhat.service.bridge.infra.exceptions.definitions.user.ActionProviderException)2