use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method getProcessor_bridgeDoesNotExist.
@Test
public void getProcessor_bridgeDoesNotExist() {
Bridge b = createPersistBridge(ManagedResourceStatus.READY);
ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
await().atMost(5, SECONDS).untilAsserted(() -> {
Processor p = processorDAO.findById(processor.getId());
assertThat(p).isNotNull();
assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
});
assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> processorService.getProcessor(processor.getId(), "doesNotExist", b.getCustomerId()));
}
use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testDeleteConnectorFailureOnKafkaTopicDeletion.
@Test
public void testDeleteConnectorFailureOnKafkaTopicDeletion() {
Bridge bridge = createPersistBridge(ManagedResourceStatus.READY);
Processor processor = Fixtures.createProcessor(bridge, "bridgeTestDelete", ManagedResourceStatus.READY);
ConnectorEntity connector = Fixtures.createConnector(processor, "connectorToBeDeleted", ManagedResourceStatus.READY, "topicName");
processorDAO.persist(processor);
connectorsDAO.persist(connector);
// Emulate successful External Connector creation
Connector externalConnector = new Connector();
final ConnectorStatusStatus externalConnectorStatus = new ConnectorStatusStatus();
externalConnectorStatus.setState(ConnectorState.READY);
externalConnector.setStatus(externalConnectorStatus);
when(connectorsApiClient.getConnector(any())).thenReturn(externalConnector);
// Emulate successful External Connector deletion
doAnswer(i -> {
externalConnectorStatus.setState(ConnectorState.DELETED);
return null;
}).when(connectorsApiClient).deleteConnector(any());
doThrow(new InternalPlatformException(createFailureErrorMessageFor("errorTopic"), new RuntimeException("error"))).when(rhoasService).deleteTopicAndRevokeAccessFor(anyString(), any());
processorService.deleteProcessor(bridge.getId(), processor.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
reloadAssertProcessorIsInStatus(processor, DEPROVISION);
waitForProcessorAndConnectorToFail(processor);
verify(rhoasService, atLeast(1)).deleteTopicAndRevokeAccessFor(eq("topicName"), eq(RhoasTopicAccessType.PRODUCER));
verify(connectorsApiClient, atLeast(1)).deleteConnector(anyString());
assertShardAsksForProcessorToBeDeletedDoesNotInclude(processor);
}
use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method updateProcessorStatus_processorDoesNotExist.
@Test
public void updateProcessorStatus_processorDoesNotExist() {
Processor p = new Processor();
p.setBridge(createPersistBridge(ManagedResourceStatus.READY));
p.setId("foo");
ProcessorDTO processor = processorService.toDTO(p);
assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> processorService.updateProcessorStatus(processor));
}
use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorsAPI method getProcessor.
@GET
@Path("{bridgeId}/processors/{processorId}")
public Response getProcessor(@NotEmpty @PathParam("bridgeId") String bridgeId, @NotEmpty @PathParam("processorId") String processorId) {
String customerId = identityResolver.resolve(jwt);
Processor processor = processorService.getProcessor(processorId, bridgeId, customerId);
return Response.ok(processorService.toResponse(processor)).build();
}
use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorDAO method findByBridgeIdAndCustomerId.
public ListResult<Processor> findByBridgeIdAndCustomerId(String bridgeId, String customerId, QueryInfo queryInfo) {
/*
* Unfortunately we can't rely on Panaches in-built Paging due the fetched join in our query
* for Processor e.g. join fetch p.bridge. Instead, we simply build a list of ids to fetch and then
* execute the join fetch as normal. So the workflow here is:
*
* - Count the number of Processors on a bridge. If > 0
* - Select the ids of the Processors that need to be retrieved based on the page/size requirements
* - Select the Processors in the list of ids, performing the fetch join of the Bridge
*/
Parameters p = Parameters.with(Bridge.CUSTOMER_ID_PARAM, customerId).and(Processor.BRIDGE_ID_PARAM, bridgeId);
Long processorCount = countProcessorsOnBridge(p);
if (processorCount == 0L) {
return new ListResult<>(emptyList(), queryInfo.getPageNumber(), processorCount);
}
int firstResult = getFirstResult(queryInfo.getPageNumber(), queryInfo.getPageSize());
TypedQuery<String> idsQuery = getEntityManager().createNamedQuery("PROCESSOR.idsByBridgeIdAndCustomerId", String.class);
addParamsToNamedQuery(p, idsQuery);
List<String> ids = idsQuery.setMaxResults(queryInfo.getPageSize()).setFirstResult(firstResult).getResultList();
List<Processor> processors = getEntityManager().createNamedQuery("PROCESSOR.findByIds", Processor.class).setParameter(IDS_PARAM, ids).getResultList();
return new ListResult<>(processors, queryInfo.getPageNumber(), processorCount);
}
Aggregations