use of com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method toResponse.
@Test
public void toResponse() {
Bridge b = Fixtures.createBridge();
Processor p = Fixtures.createProcessor(b, "foo", ManagedResourceStatus.READY);
BaseAction action = Fixtures.createKafkaAction();
ProcessorDefinition definition = new ProcessorDefinition(Collections.emptySet(), "", action);
p.setDefinition(definitionToJsonNode(definition));
ProcessorResponse r = processorService.toResponse(p);
assertThat(r).isNotNull();
assertThat(r.getHref()).isEqualTo(APIConstants.USER_API_BASE_PATH + b.getId() + "/processors/" + p.getId());
assertThat(r.getName()).isEqualTo(p.getName());
assertThat(r.getStatus()).isEqualTo(p.getStatus());
assertThat(r.getId()).isEqualTo(p.getId());
assertThat(r.getSubmittedAt()).isEqualTo(p.getSubmittedAt());
assertThat(r.getPublishedAt()).isEqualTo(p.getPublishedAt());
assertThat(r.getKind()).isEqualTo("Processor");
assertThat(r.getTransformationTemplate()).isEmpty();
assertThat(r.getAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
}
use of com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorSteps method processorOfBridgeHasActionOfTypeAndParameters.
@And("^the Processor \"([^\"]*)\" of the Bridge \"([^\"]*)\" has action of type \"([^\"]*)\" and parameters:$")
public void processorOfBridgeHasActionOfTypeAndParameters(String processorName, String testBridgeName, String actionType, DataTable parametersDatatable) {
BridgeContext bridgeContext = context.getBridge(testBridgeName);
String processorId = bridgeContext.getProcessor(processorName).getId();
ProcessorResponse response = ProcessorResource.getProcessor(context.getManagerToken(), bridgeContext.getId(), processorId);
BaseAction action = response.getAction();
assertThat(action.getType()).isEqualTo(actionType);
parametersDatatable.asMap().forEach((key, value) -> {
assertThat(action.getParameters()).containsEntry(key, value);
});
}
use of com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method listProcessors.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessors() {
BridgeResponse bridgeResponse = createAndDeployBridge();
ProcessorResponse p = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", createKafkaAction())).as(ProcessorResponse.class);
ProcessorResponse p2 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor2", createKafkaAction())).as(ProcessorResponse.class);
ProcessorListResponse listResponse = TestUtils.listProcessors(bridgeResponse.getId(), 0, 100).as(ProcessorListResponse.class);
assertThat(listResponse.getPage()).isZero();
assertThat(listResponse.getSize()).isEqualTo(2L);
assertThat(listResponse.getTotal()).isEqualTo(2L);
listResponse.getItems().forEach((i) -> assertThat(i.getId()).isIn(p.getId(), p2.getId()));
}
use of com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse 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);
}
use of com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method listProcessors_pageOffset.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessors_pageOffset() {
BridgeResponse bridgeResponse = createAndDeployBridge();
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", createKafkaAction())).as(ProcessorResponse.class);
ProcessorResponse p2 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor2", createKafkaAction())).as(ProcessorResponse.class);
ProcessorListResponse listResponse = TestUtils.listProcessors(bridgeResponse.getId(), 1, 1).as(ProcessorListResponse.class);
assertThat(listResponse.getPage()).isEqualTo(1L);
assertThat(listResponse.getSize()).isEqualTo(1L);
assertThat(listResponse.getTotal()).isEqualTo(2L);
assertThat(listResponse.getItems().get(0).getId()).isEqualTo(p2.getId());
assertRequestedAction(listResponse.getItems().get(0));
}
Aggregations