use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.
the class DiagnosticsUpgradeTelemetryHandlerTest method testDoAccept.
@Test
public void testDoAccept() throws CloudbreakOrchestratorFailedException {
// GIVEN
doNothing().when(telemetryUpgradeService).upgradeTelemetryComponent(anyLong(), any(), any());
// WHEN
DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(UPGRADE_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
// THEN
verify(telemetryUpgradeService, times(1)).upgradeTelemetryComponent(anyLong(), any(), any());
}
use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.
the class DiagnosticsUploadHandlerTest method testDoAccept.
@Test
public void testDoAccept() throws CloudbreakOrchestratorFailedException {
// GIVEN
doNothing().when(diagnosticsOperationsService).upload(anyLong(), any());
// WHEN
DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(UPLOAD_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
// THEN
verify(diagnosticsOperationsService, times(1)).upload(anyLong(), any());
}
use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.
the class DiagnosticsUploadHandlerTest method testDoAcceptOnError.
@Test
public void testDoAcceptOnError() throws CloudbreakOrchestratorFailedException {
// GIVEN
doThrow(new CloudbreakOrchestratorFailedException("ex")).when(diagnosticsOperationsService).upload(anyLong(), any());
// WHEN
DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(UPLOAD_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
DiagnosticsFlowException result = assertThrows(DiagnosticsFlowException.class, () -> underTest.doAccept(new HandlerEvent<>(new Event<>(event))));
// THEN
assertTrue(result.getMessage().contains("Error during diagnostics operation: Upload"));
}
use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.
the class DiagnosticsVmPreFlightCheckHandlerTest method testDoAcceptOnError.
@Test
public void testDoAcceptOnError() throws CloudbreakOrchestratorFailedException {
// GIVEN
doThrow(new CloudbreakOrchestratorFailedException("ex")).when(diagnosticsOperationsService).vmPreflightCheck(anyLong(), any());
// WHEN
DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(VM_PREFLIGHT_CHECK_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
DiagnosticsFlowException result = assertThrows(DiagnosticsFlowException.class, () -> underTest.doAccept(new HandlerEvent<>(new Event<>(event))));
// THEN
assertTrue(result.getMessage().contains("Error during diagnostics operation: VM Pre-flight check"));
}
use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.
the class KerberosBindUserCreationHandlerTest method testCreated.
@Test
public void testCreated() throws FreeIpaClientException {
CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
CreateKerberosBindUserEvent createKerberosBindUserEvent = new CreateKerberosBindUserEvent(createBindUserEvent);
HandlerEvent<CreateKerberosBindUserEvent> handlerEvent = new HandlerEvent<>(new Event<>(createKerberosBindUserEvent));
when(kerberosConfigService.find(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId(), createBindUserEvent.getSuffix())).thenReturn(Optional.empty());
Stack stack = new Stack();
when(stackService.getByEnvironmentCrnAndAccountId(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId())).thenReturn(stack);
Selectable selectable = underTest.doAccept(handlerEvent);
assertTrue(selectable instanceof CreateBindUserEvent);
CreateBindUserEvent event = (CreateBindUserEvent) selectable;
assertEquals(CreateBindUserFlowEvent.CREATE_KERBEROS_BIND_USER_FINISHED_EVENT.event(), event.selector());
assertEquals(createBindUserEvent.getOperationId(), event.getOperationId());
assertEquals(createBindUserEvent.getSuffix(), event.getSuffix());
assertEquals(createBindUserEvent.getAccountId(), event.getAccountId());
assertEquals(createBindUserEvent.getResourceId(), event.getResourceId());
verify(stackService).getByEnvironmentCrnAndAccountId(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId());
verify(kerberosConfigV1Service).createNewKerberosConfig(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getSuffix(), stack, true);
}
Aggregations