use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class DatalakeRecoverySetupNewInstancesHandlerTest method testDoAcceptWhenExceptionThenFailure.
@Test
void testDoAcceptWhenExceptionThenFailure() {
when(stackService.getByIdWithClusterInTransaction(STACK_ID)).thenThrow(new NotFoundException(EXCEPTION_MESSAGE));
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent());
assertEquals(EventSelectorUtil.selector(DatalakeRecoverySetupNewInstancesFailedEvent.class), nextFlowStepSelector.selector());
DatalakeRecoverySetupNewInstancesFailedEvent failureEvent = (DatalakeRecoverySetupNewInstancesFailedEvent) nextFlowStepSelector;
assertEquals(EXCEPTION_MESSAGE, failureEvent.getException().getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class SdxBackupController method backupDatabaseByName.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.BACKUP_DATALAKE)
public SdxDatabaseBackupResponse backupDatabaseByName(@ResourceName String name, String backupId, String backupLocation) {
SdxCluster sdxCluster = getSdxClusterByName(name);
try {
SdxDatabaseBackupStatusResponse response = sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId);
SdxDatabaseBackupResponse sdxDatabaseBackupResponse = new SdxDatabaseBackupResponse();
sdxDatabaseBackupResponse.setOperationId(backupId);
return sdxDatabaseBackupResponse;
} catch (NotFoundException notFoundException) {
SdxDatabaseBackupRequest backupRequest = new SdxDatabaseBackupRequest();
backupRequest.setBackupId(backupId);
backupRequest.setBackupLocation(backupLocation);
backupRequest.setCloseConnections(true);
return sdxBackupRestoreService.triggerDatabaseBackup(sdxCluster, backupRequest);
}
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxResizeByAccountIdAndNameWhenSdxDoesNotExist.
@Test
void testSdxResizeByAccountIdAndNameWhenSdxDoesNotExist() {
SdxClusterResizeRequest sdxClusterResizeRequest = new SdxClusterResizeRequest();
sdxClusterResizeRequest.setClusterShape(MEDIUM_DUTY_HA);
sdxClusterResizeRequest.setEnvironment("environment");
when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(Optional.empty());
NotFoundException notFoundException = assertThrows(NotFoundException.class, () -> underTest.resizeSdx(USER_CRN, "sdxcluster", sdxClusterResizeRequest));
assertEquals("SDX cluster 'sdxcluster' not found.", notFoundException.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class DatabaseServiceTest method testGetDatabaseServerWhenNoDatabaseCrnShouldThrowNotFoundException.
@Test
public void testGetDatabaseServerWhenNoDatabaseCrnShouldThrowNotFoundException() {
when(sdxService.getByCrn(USER_CRN, CLUSTER_CRN)).thenReturn(new SdxCluster());
NotFoundException exception = assertThrows(NotFoundException.class, () -> underTest.getDatabaseServer(USER_CRN, CLUSTER_CRN));
assertThat(exception.getMessage()).isEqualTo("Database for Data Lake with Data Lake crn: 'cluster crn' not found.");
verify(databaseServerV4Endpoint, never()).getByCrn(anyString());
}
use of com.sequenceiq.cloudbreak.common.exception.NotFoundException in project cloudbreak by hortonworks.
the class SdxBackupRestoreServiceTest method testgetDatabaseBackupStatus.
@Test
public void testgetDatabaseBackupStatus() {
when(sdxOperationRepository.findSdxOperationByOperationId(Mockito.anyString())).thenReturn(null);
try {
sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, BACKUP_ID);
fail("Exception should have been thrown");
} catch (NotFoundException notFoundException) {
String exceptedMessage = String.format("Status with id: [%s] not found", BACKUP_ID);
assertEquals(exceptedMessage, notFoundException.getLocalizedMessage());
}
reset(sdxOperationRepository);
SdxOperation sdxOperation = new SdxOperation();
sdxOperation.setOperationType(SdxOperationType.RESTORE);
sdxOperation.setSdxClusterId(sdxCluster.getId());
sdxOperation.setOperationId(BACKUP_ID);
when(sdxOperationRepository.findSdxOperationByOperationId(Mockito.anyString())).thenReturn(sdxOperation);
try {
sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, BACKUP_ID);
fail("Exception should have been thrown");
} catch (CloudbreakApiException cloudbreakApiException) {
String exceptedMessage = String.format("Invalid operation-id: [%s]. provided", BACKUP_ID);
assertEquals(exceptedMessage, cloudbreakApiException.getLocalizedMessage());
}
}
Aggregations