use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceConnectorTest method createPersistBridge.
private Bridge createPersistBridge(ManagedResourceStatus status) {
Bridge b = Fixtures.createBridge();
b.setStatus(status);
bridgeDAO.persist(b);
return b;
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceConnectorTest method createConnectorFailureOnKafkaTopicCreation.
@Test
void createConnectorFailureOnKafkaTopicCreation() {
Bridge b = createPersistBridge(READY);
Action slackAction = createSlackAction();
ProcessorRequest processorRequest = new ProcessorRequest("ManagedConnectorProcessor", slackAction);
when(rhoasService.createTopicAndGrantAccessFor(anyString(), any())).thenThrow(new InternalPlatformException(RhoasServiceImpl.createFailureErrorMessageFor("errorTopic"), new RuntimeException("error")));
when(connectorsApiClient.createConnector(any(ConnectorRequest.class))).thenReturn(new Connector());
Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), b.getOwner(), processorRequest);
waitForProcessorAndConnectorToFail(processor);
verify(rhoasService, atLeast(1)).createTopicAndGrantAccessFor(anyString(), eq(RhoasTopicAccessType.PRODUCER));
verify(connectorsApiClient, never()).createConnector(any(ConnectorRequest.class));
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method cleanUp.
@BeforeEach
public void cleanUp() {
reset(bridgesServiceMock);
reset(processorDAO);
Bridge bridge = createReadyBridge();
Processor processor = createReadyProcessor();
Processor provisioningProcessor = createProvisioningProcessor();
Processor failedProcessor = createFailedProcessor();
Processor errorHandlerProcessor = createErrorHandlerProcessor();
when(bridgesServiceMock.getBridge(DEFAULT_BRIDGE_ID)).thenReturn(bridge);
when(bridgesServiceMock.getBridge(not(eq(DEFAULT_BRIDGE_ID)))).thenThrow(new ItemNotFoundException("Bridge not found"));
when(bridgesServiceMock.getBridge(DEFAULT_BRIDGE_ID, DEFAULT_CUSTOMER_ID)).thenReturn(bridge);
when(bridgesServiceMock.getBridge(not(eq(DEFAULT_BRIDGE_ID)), eq(DEFAULT_CUSTOMER_ID))).thenThrow(new ItemNotFoundException("Bridge not found"));
when(bridgesServiceMock.getBridge(any(), not(eq(DEFAULT_CUSTOMER_ID)))).thenThrow(new ItemNotFoundException("Bridge not found"));
when(bridgesServiceMock.getReadyBridge(DEFAULT_BRIDGE_ID, DEFAULT_CUSTOMER_ID)).thenReturn(bridge);
when(bridgesServiceMock.getReadyBridge(NOT_READY_BRIDGE_ID, DEFAULT_CUSTOMER_ID)).thenThrow(new BridgeLifecycleException("Bridge not ready"));
when(bridgesServiceMock.getReadyBridge(not(or(eq(DEFAULT_BRIDGE_ID), eq(NOT_READY_BRIDGE_ID))), eq(DEFAULT_CUSTOMER_ID))).thenThrow(new ItemNotFoundException("Bridge not found"));
when(processorDAO.findById(DEFAULT_PROCESSOR_ID)).thenReturn(processor);
when(processorDAO.findByBridgeIdAndName(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_NAME)).thenReturn(processor);
when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(processor);
when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, PROVISIONING_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(provisioningProcessor);
when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, FAILED_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(failedProcessor);
when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, ERROR_HANDLER_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(errorHandlerProcessor);
when(processorDAO.findUserVisibleByBridgeIdAndCustomerId(eq(DEFAULT_BRIDGE_ID), eq(DEFAULT_CUSTOMER_ID), any())).thenReturn(new ListResult<>(List.of(processor, provisioningProcessor, failedProcessor), 0, 3));
when(processorDAO.countByBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_CUSTOMER_ID)).thenReturn(3L);
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testToResponse.
@Test
void testToResponse() {
Bridge b = Fixtures.createBridge();
Processor p = Fixtures.createProcessor(b, READY);
Action action = Fixtures.createKafkaAction();
ProcessorDefinition definition = new ProcessorDefinition(Collections.emptySet(), "", action);
p.setDefinition(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.getType()).isEqualTo(p.getType());
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.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesAPITest method testGetBridgesFilterByName.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testGetBridgesFilterByName() {
Bridge bridge1 = Fixtures.createBridge();
bridge1.setName(DEFAULT_BRIDGE_NAME + "1");
bridge1.setStatus(ACCEPTED);
bridgeDAO.persist(bridge1);
Bridge bridge2 = Fixtures.createBridge();
bridge2.setName(DEFAULT_BRIDGE_NAME + "2");
bridge2.setStatus(ACCEPTED);
bridgeDAO.persist(bridge2);
BridgeListResponse bridgeListResponse = TestUtils.getBridgesFilterByName(DEFAULT_BRIDGE_NAME + "1").as(BridgeListResponse.class);
assertThat(bridgeListResponse.getItems().size()).isEqualTo(1);
BridgeResponse bridgeResponse = bridgeListResponse.getItems().get(0);
assertThat(bridgeResponse.getName()).isEqualTo(bridge1.getName());
assertThat(bridgeResponse.getStatus()).isEqualTo(bridge1.getStatus());
assertThat(bridgeResponse.getHref()).isEqualTo(USER_API_BASE_PATH + bridgeResponse.getId());
assertThat(bridgeResponse.getSubmittedAt()).isNotNull();
assertThat(bridgeResponse.getEndpoint()).isNotNull();
}
Aggregations