use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class ErrorMessageTest method shouldReturnRightErrorMessageWhenDatasetStillInUseThrown.
@Test
public void shouldReturnRightErrorMessageWhenDatasetStillInUseThrown() {
// given
ErrorCode errorCode = DATASET_STILL_IN_USE;
// when
TDPException exception = new TDPException(errorCode, null, null);
// then
assertEquals(errorCode, exception.getCode());
assertEquals("You cannot delete the dataset, it is being used by preparation(s)", exception.getMessage());
assertEquals("Deletion forbidden", exception.getMessageTitle());
assertFalse(exception.getContext().entries().iterator().hasNext());
}
use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class ErrorMessageTest method shouldReturnRightErrorMessageWhenPreparationStepCannotBeDeletedInSingleModeThrown.
@Test
public void shouldReturnRightErrorMessageWhenPreparationStepCannotBeDeletedInSingleModeThrown() {
// given
ErrorCode errorCode = PREPARATION_STEP_CANNOT_BE_DELETED_IN_SINGLE_MODE;
// when
TDPException exception = new TDPException(errorCode, null, null);
// then
assertEquals(errorCode, exception.getCode());
assertEquals("This action cannot be deleted because subsequent actions depend on it", exception.getMessage());
assertEquals("Delete action not authorized", exception.getMessageTitle());
assertFalse(exception.getContext().entries().iterator().hasNext());
}
use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class ErrorMessageTest method shouldReturnRightErrorMessageWhenUnsupportedContentThrown.
@Test
public void shouldReturnRightErrorMessageWhenUnsupportedContentThrown() {
// given
ErrorCode errorCode = UNSUPPORTED_CONTENT;
// when
TDPException exception = new TDPException(errorCode, null, null);
// then
assertEquals(errorCode, exception.getCode());
assertEquals("Unable to create dataset, content is not supported. Try with a csv or xls file!", exception.getMessage());
assertEquals("Unsupported content", exception.getMessageTitle());
assertFalse(exception.getContext().entries().iterator().hasNext());
}
use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class DefaultsTest method shouldPipeInputStream_handleIOError.
@Test
public void shouldPipeInputStream_handleIOError() throws Exception {
// When
final BasicHttpResponse response = buildResponse();
response.setEntity(new StringEntity("") {
@Override
public InputStream getContent() throws IOException {
throw new IOException("Unexpected exception");
}
});
try {
Defaults.pipeStream().apply(buildRequest(), response);
} catch (TDPException e) {
// Then
assertEquals(CommonErrorCodes.UNEXPECTED_EXCEPTION, e.getCode());
}
}
use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class DefaultsTest method shoudPassthrough.
@Test
public void shoudPassthrough() throws Exception {
// Given
final RuntimeException runtimeException = new RuntimeException();
final Exception exception = new Exception();
// When
try {
Defaults.passthrough().apply(runtimeException);
} catch (Exception e) {
// Then
assertEquals(runtimeException, e);
}
// When
try {
Defaults.passthrough().apply(exception);
} catch (TDPException e) {
// Then
assertEquals(CommonErrorCodes.UNEXPECTED_EXCEPTION, e.getCode());
}
}
Aggregations