Search in sources :

Example 36 with ProcessorRequest

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

the class ProcessorAPITest method updateProcessorWithAction.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithAction() {
    Bridge bridge = Fixtures.createBridge();
    bridgeDAO.persist(bridge);
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("key", "value"));
    Response createResponse = TestUtils.addProcessorToBridge(bridge.getId(), new ProcessorRequest("myProcessor", filters, null, TestUtils.createKafkaAction()));
    ProcessorResponse processor = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
    setProcessorAsReady(processor.getId());
    Response response = TestUtils.updateProcessor(bridge.getId(), processor.getId(), new ProcessorRequest(processor.getName(), filters, processor.getTransformationTemplate(), null));
    assertThat(response.getStatusCode()).isEqualTo(400);
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.smartevents.manager.models.Bridge) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 37 with ProcessorRequest

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

the class ProcessorAPITest method addProcessorToBridge_noNameSuppliedForProcessor.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridge_noNameSuppliedForProcessor() {
    Response response = TestUtils.addProcessorToBridge(TestConstants.DEFAULT_BRIDGE_NAME, new ProcessorRequest());
    assertThat(response.getStatusCode()).isEqualTo(400);
}
Also used : ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 38 with ProcessorRequest

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

the class ProcessorAPITest method addProcessorToBridgeNoAuthentication.

@Test
public void addProcessorToBridgeNoAuthentication() {
    Response response = TestUtils.addProcessorToBridge(TestConstants.DEFAULT_BRIDGE_NAME, new ProcessorRequest());
    assertThat(response.getStatusCode()).isEqualTo(401);
}
Also used : ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 39 with ProcessorRequest

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

the class ProcessorAPITest method updateProcessorWithFilter.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithFilter() {
    Bridge bridge = Fixtures.createBridge();
    bridgeDAO.persist(bridge);
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("key", "value"));
    Response createResponse = TestUtils.addProcessorToBridge(bridge.getId(), new ProcessorRequest("myProcessor", filters, null, TestUtils.createKafkaAction()));
    ProcessorResponse processor = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
    setProcessorAsReady(processor.getId());
    Set<BaseFilter> updatedFilters = Set.of(new StringEquals("key1", "value1"), new StringEquals("key2", "value2"));
    Response response = TestUtils.updateProcessor(bridge.getId(), processor.getId(), new ProcessorRequest(processor.getName(), updatedFilters, processor.getTransformationTemplate(), processor.getAction()));
    assertThat(response.getStatusCode()).isEqualTo(202);
    ProcessorResponse updated = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
    assertThat(updated.getName()).isEqualTo("myProcessor");
    assertThat(updated.getFilters().size()).isEqualTo(2);
    assertThat(updated.getFilters().stream().filter(f -> f.getKey().equals("key1") && f.getValue().equals("value1")).count()).isEqualTo(1);
    assertThat(updated.getFilters().stream().filter(f -> f.getKey().equals("key2") && f.getValue().equals("value2")).count()).isEqualTo(1);
    assertThat(updated.getTransformationTemplate()).isNull();
    assertRequestedAction(updated);
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) BeforeEach(org.junit.jupiter.api.BeforeEach) Action(com.redhat.service.smartevents.infra.models.gateways.Action) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) BridgeDAO(com.redhat.service.smartevents.manager.dao.BridgeDAO) DatabaseManagerUtils(com.redhat.service.smartevents.manager.utils.DatabaseManagerUtils) SOURCE(com.redhat.service.smartevents.infra.models.processors.ProcessorType.SOURCE) TestUtils(com.redhat.service.smartevents.manager.utils.TestUtils) DEFAULT_USER_NAME(com.redhat.service.smartevents.manager.TestConstants.DEFAULT_USER_NAME) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) Map(java.util.Map) TypeRef(io.restassured.common.mapper.TypeRef) Awaitility.await(org.awaitility.Awaitility.await) Transactional(javax.transaction.Transactional) TestProfile(io.quarkus.test.junit.TestProfile) Set(java.util.Set) Test(org.junit.jupiter.api.Test) APIConstants(com.redhat.service.smartevents.infra.api.APIConstants) List(java.util.List) BridgeDTO(com.redhat.service.smartevents.infra.models.dto.BridgeDTO) Fixtures(com.redhat.service.smartevents.manager.utils.Fixtures) StringIn(com.redhat.service.smartevents.infra.models.filters.StringIn) ACCEPTED(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.ACCEPTED) TestSecurity(io.quarkus.test.security.TestSecurity) ProcessorDAO(com.redhat.service.smartevents.manager.dao.ProcessorDAO) READY(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.READY) TestConstants(com.redhat.service.smartevents.manager.TestConstants) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) HashMap(java.util.HashMap) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) ArrayList(java.util.ArrayList) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Inject(javax.inject.Inject) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Processor(com.redhat.service.smartevents.manager.models.Processor) SlackAction(com.redhat.service.smartevents.processor.actions.slack.SlackAction) USER_NAME_ATTRIBUTE_CLAIM(com.redhat.service.smartevents.infra.api.APIConstants.USER_NAME_ATTRIBUTE_CLAIM) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) InjectMock(io.quarkus.test.junit.mockito.InjectMock) Mockito.when(org.mockito.Mockito.when) WorkerSchedulerProfile(com.redhat.service.smartevents.manager.WorkerSchedulerProfile) Bridge(com.redhat.service.smartevents.manager.models.Bridge) Response(io.restassured.response.Response) JsonWebToken(org.eclipse.microprofile.jwt.JsonWebToken) RhoasService(com.redhat.service.smartevents.manager.RhoasService) ManagedResourceStatus(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus) BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) SendToBridgeAction(com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.smartevents.manager.models.Bridge) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 40 with ProcessorRequest

use of com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest 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.smartevents.infra.models.filters.StringEquals) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)59 Test (org.junit.jupiter.api.Test)49 QuarkusTest (io.quarkus.test.junit.QuarkusTest)47 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)41 TestSecurity (io.quarkus.test.security.TestSecurity)40 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)36 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)36 Response (io.restassured.response.Response)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)11 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)11 Bridge (com.redhat.service.smartevents.manager.models.Bridge)11 Action (com.redhat.service.smartevents.infra.models.gateways.Action)10 Processor (com.redhat.service.smartevents.manager.models.Processor)8 SlackAction (com.redhat.service.smartevents.processor.actions.slack.SlackAction)8 MethodSource (org.junit.jupiter.params.provider.MethodSource)8 BridgeDTO (com.redhat.service.smartevents.infra.models.dto.BridgeDTO)6 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)6 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)6 SendToBridgeAction (com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)6