Search in sources :

Example 6 with TerminateExternalDatabaseRequest

use of com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.TerminateExternalDatabaseRequest in project cloudbreak by hortonworks.

the class TerminateExternalDatabaseHandlerTest method acceptDbNone.

@Test
void acceptDbNone() {
    when(stackService.getById(anyLong())).thenReturn(buildStack(DatabaseAvailabilityType.NONE));
    TerminateExternalDatabaseRequest request = new TerminateExternalDatabaseRequest(STACK_ID, "selector", "resourceName", "crn", false);
    Event<TerminateExternalDatabaseRequest> event = new Event<>(EVENT_HEADERS, request);
    underTest.accept(event);
    verifyNoMoreInteractions(terminationService);
    verifyNoMoreInteractions(stackUpdaterService);
    ArgumentCaptor<Event<TerminateExternalDatabaseResult>> eventCaptor = ArgumentCaptor.forClass(Event.class);
    verify(eventBus).notify(eq("TerminateExternalDatabaseResult"), eventCaptor.capture());
    Event<TerminateExternalDatabaseResult> value = eventCaptor.getValue();
    assertThat(value.getHeaders()).isEqualTo(EVENT_HEADERS);
    assertThat(value.getData().getResourceCrn()).isNull();
}
Also used : TerminateExternalDatabaseResult(com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.TerminateExternalDatabaseResult) Event(reactor.bus.Event) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) TerminateExternalDatabaseRequest(com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.TerminateExternalDatabaseRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TerminateExternalDatabaseRequest (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.TerminateExternalDatabaseRequest)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)3 TerminateExternalDatabaseResult (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.TerminateExternalDatabaseResult)3 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)3 ValueSource (org.junit.jupiter.params.provider.ValueSource)3 Event (reactor.bus.Event)3 DatabaseAvailabilityType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)2 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 TerminationEvent (com.sequenceiq.cloudbreak.reactor.api.event.stack.TerminationEvent)2 PollerException (com.dyngr.exception.PollerException)1 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 UserBreakException (com.dyngr.exception.UserBreakException)1 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 ExternalDatabaseContext (com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext)1 AbstractExternalDatabaseTerminationAction (com.sequenceiq.cloudbreak.core.flow2.externaldatabase.terminate.action.AbstractExternalDatabaseTerminationAction)1 ExternalDatabaseTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.externaldatabase.terminate.config.ExternalDatabaseTerminationEvent)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1