Search in sources :

Example 6 with CmSyncRequest

use of com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncRequest in project cloudbreak by hortonworks.

the class CmSyncHandlerTest method testAcceptWhenStackNotFound.

@Test
void testAcceptWhenStackNotFound() {
    Set<String> candidateImageUuids = Set.of(IMAGE_UUID_1);
    HandlerEvent<CmSyncRequest> event = getCmSyncRequestHandlerEvent(candidateImageUuids);
    Exception exception = new CloudbreakServiceException("errordetail");
    when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenThrow(exception);
    CmSyncResult result = (CmSyncResult) underTest.doAccept(event);
    assertEquals("CMSYNCRESULT_ERROR", result.selector());
    assertThat(result.getErrorDetails(), instanceOf(CloudbreakServiceException.class));
    assertEquals("unexpected error: errordetail", result.getErrorDetails().getMessage());
    assertEquals("unexpected error: errordetail", result.getStatusReason());
    verify(stackService).getByIdWithListsInTransaction(STACK_ID);
    verify(cmSyncImageCollectorService, never()).collectImages(anyString(), any(), any());
    verify(cmSyncerService, never()).syncFromCmToDb(any(), any());
}
Also used : CmSyncResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncResult) CmSyncRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncRequest) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Test(org.junit.jupiter.api.Test)

Aggregations

CmSyncRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncRequest)6 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)3 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 CmSyncResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.CmSyncResult)3 CmSyncOperationStatus (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationStatus)3 CmSyncOperationSummary (com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmSyncOperationSummary)3 Test (org.junit.jupiter.api.Test)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 CmSyncTriggerEvent (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.CmSyncTriggerEvent)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1