Search in sources :

Example 1 with StartBindUserCreationEvent

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);
        }
    };
}
Also used : StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) AbstractStackCreationAction(com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Optional(java.util.Optional) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with StartBindUserCreationEvent

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());
}
Also used : StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Event(reactor.bus.Event) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) RetryException(com.sequenceiq.cloudbreak.retry.RetryException) Test(org.junit.jupiter.api.Test)

Example 3 with StartBindUserCreationEvent

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());
}
Also used : StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Event(reactor.bus.Event) RetryException(com.sequenceiq.cloudbreak.retry.RetryException) Test(org.junit.jupiter.api.Test)

Example 4 with StartBindUserCreationEvent

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);
}
Also used : StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Event(reactor.bus.Event) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Test(org.junit.jupiter.api.Test)

Aggregations

StartBindUserCreationEvent (com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent)4 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)4 StackFailureEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent)4 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)3 Test (org.junit.jupiter.api.Test)3 Event (reactor.bus.Event)3 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)2 RetryException (com.sequenceiq.cloudbreak.retry.RetryException)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 AbstractStackCreationAction (com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction)1 StackCreationContext (com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1