use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent in project cloudbreak by hortonworks.
the class KerberosConfigValidationActions method createBindUserAction.
@Bean(name = "CREATE_BIND_USER_STATE")
public Action<?, ?> createBindUserAction() {
return new AbstractStackCreationAction<>(StackEvent.class) {
@Override
protected void doExecute(StackCreationContext context, StackEvent payload, Map<Object, Object> variables) {
StartBindUserCreationEvent event = new StartBindUserCreationEvent(payload.getResourceId());
sendEvent(context, event);
}
@Override
protected Object getFailurePayload(StackEvent payload, Optional<StackCreationContext> flowContext, Exception ex) {
return new StackFailureEvent(KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.selector(), payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent in project cloudbreak by hortonworks.
the class StartBindUserCreationHandlerTest method testRetryExceptionReceived.
@Test
public void testRetryExceptionReceived() {
StackView stackView = new StackView();
stackView.setId(1L);
when(stackViewService.getById(1L)).thenReturn(stackView);
Event<StartBindUserCreationEvent> event = new Event<>(new StartBindUserCreationEvent(1L));
RetryException retryException = new RetryException();
when(startBindUserCreationService.startBindUserCreation(stackView)).thenThrow(retryException);
StackFailureEvent result = (StackFailureEvent) underTest.doAccept(new HandlerEvent<>(event));
assertEquals(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), result.selector());
assertEquals(1L, result.getResourceId());
assertEquals(retryException, result.getException());
}
use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent in project cloudbreak by hortonworks.
the class StartBindUserCreationHandlerTest method testDefaultFailureEvent.
@Test
public void testDefaultFailureEvent() {
Event<StartBindUserCreationEvent> event = new Event<>(new StartBindUserCreationEvent(1L));
Exception e = new Exception();
StackFailureEvent result = (StackFailureEvent) underTest.defaultFailureEvent(1L, e, event);
assertEquals(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), result.selector());
assertEquals(1L, result.getResourceId());
assertEquals(e, result.getException());
}
use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent in project cloudbreak by hortonworks.
the class StartBindUserCreationHandlerTest method testSuccess.
@Test
public void testSuccess() {
StackView stackView = new StackView();
stackView.setId(1L);
when(stackViewService.getById(1L)).thenReturn(stackView);
Event<StartBindUserCreationEvent> event = new Event<>(new StartBindUserCreationEvent(1L));
StackEvent expectedEvent = new StackEvent(1L);
when(startBindUserCreationService.startBindUserCreation(stackView)).thenReturn(expectedEvent);
Selectable result = underTest.doAccept(new HandlerEvent<>(event));
assertEquals(expectedEvent, result);
}
Aggregations