use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorsAPI method updateProcessor.
@APIResponses(value = { @APIResponse(description = "Accepted.", responseCode = "202", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = ProcessorResponse.class))), @APIResponse(description = "Bad request.", responseCode = "400", content = @Content(mediaType = MediaType.APPLICATION_JSON)), @APIResponse(description = "Unauthorized.", responseCode = "401"), @APIResponse(description = "Forbidden.", responseCode = "403"), @APIResponse(description = "Not found.", responseCode = "404", content = @Content(mediaType = MediaType.APPLICATION_JSON)), @APIResponse(description = "Internal error.", responseCode = "500", content = @Content(mediaType = MediaType.APPLICATION_JSON)) })
@Operation(summary = "Update a Processor instance Filter definition or Transformation template.", description = "Update a Processor instance Filter definition or Transformation template for the authenticated user.")
@PUT
@Path("{bridgeId}/processors/{processorId}")
public Response updateProcessor(@NotEmpty @PathParam("bridgeId") String bridgeId, @NotEmpty @PathParam("processorId") String processorId, @Valid ProcessorRequest processorRequest) {
String customerId = identityResolver.resolve(jwt);
Processor processor = processorService.updateProcessor(bridgeId, processorId, customerId, processorRequest);
return Response.accepted(processorService.toResponse(processor)).build();
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method setProcessorStatus.
@Transactional
protected void setProcessorStatus(String processorId, ManagedResourceStatus status) {
Processor processor = processorDAO.findById(processorId);
processor.setStatus(status);
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method testDeleteProcessor.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testDeleteProcessor() {
Bridge bridge = Fixtures.createBridge();
bridge.setStatus(READY);
bridgeDAO.persist(bridge);
Processor processor = Fixtures.createProcessor(bridge, READY);
processorDAO.persist(processor);
TestUtils.deleteProcessor(bridge.getId(), processor.getId()).then().statusCode(202);
ProcessorResponse processorResponse = TestUtils.getProcessor(bridge.getId(), processor.getId()).as(ProcessorResponse.class);
assertThat(processorResponse.getStatus()).isEqualTo(ManagedResourceStatus.DEPROVISION);
}
use of com.redhat.service.smartevents.manager.models.Processor 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);
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method updateProcessorWhenProcessorNotInReadyState.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWhenProcessorNotInReadyState() {
Bridge bridge = Fixtures.createBridge();
bridgeDAO.persist(bridge);
Processor processor = Fixtures.createProcessor(bridge, ManagedResourceStatus.PROVISIONING);
processorDAO.persist(processor);
Response response = TestUtils.updateProcessor(bridge.getId(), processor.getId(), new ProcessorRequest(processor.getName(), Collections.emptySet(), null, TestUtils.createKafkaAction()));
assertThat(response.getStatusCode()).isEqualTo(400);
}
Aggregations