### Question:
JobResultSerializer extends Serializer<BaseProtocol.JobResult<?>> { @VisibleForTesting static RuntimeException convertToSerializableSparkException(Throwable error) { RuntimeException serializableThrowable = new RuntimeException( error.getClass().getName() + ": " + Objects.toString(error.getMessage(), ""), error.getCause() == null ? null : convertToSerializableSparkException( error.getCause())); serializableThrowable.setStackTrace(error.getStackTrace()); Arrays.stream(error.getSuppressed()) .map(JobResultSerializer::convertToSerializableSparkException) .forEach(serializableThrowable::addSuppressed); return serializableThrowable; }  @Override BaseProtocol.JobResult<?> read(Kryo kryo, Input input, Class type); @Override void write(Kryo kryo, Output output, BaseProtocol.JobResult<?> object);  }### Answer:
@Test public void testSerializablableExceptionNestedBlankException() { RuntimeException nestedBlankRuntimeException = new RuntimeException(); RuntimeException blankRuntimeException = new RuntimeException(nestedBlankRuntimeException); RuntimeException serializableException = JobResultSerializer.convertToSerializableSparkException( blankRuntimeException); assertNestedException(serializableException, blankRuntimeException); }
@Test public void testSerializablableExceptionNestedException() { RuntimeException nestedRuntimeException = new RuntimeException("hello"); RuntimeException blankRuntimeException = new RuntimeException(nestedRuntimeException); RuntimeException serializableException = JobResultSerializer.convertToSerializableSparkException( blankRuntimeException); assertNestedException(serializableException, blankRuntimeException); nestedRuntimeException = new RuntimeException(); blankRuntimeException = new RuntimeException("hello", nestedRuntimeException); serializableException = JobResultSerializer.convertToSerializableSparkException( blankRuntimeException); assertNestedException(serializableException, blankRuntimeException); nestedRuntimeException = new RuntimeException("hello"); blankRuntimeException = new RuntimeException("hello", nestedRuntimeException); serializableException = JobResultSerializer.convertToSerializableSparkException( blankRuntimeException); assertNestedException(serializableException, blankRuntimeException); }
@Test public void testSerializablableExceptionSingleBlankException() { RuntimeException blankRuntimeException = new RuntimeException(); RuntimeException serializableException = JobResultSerializer.convertToSerializableSparkException( blankRuntimeException); assertException(serializableException, blankRuntimeException); }
@Test public void testSerializablableExceptionSingleException() { RuntimeException blankRuntimeException = new RuntimeException("hello"); RuntimeException serializableException = JobResultSerializer.convertToSerializableSparkException( blankRuntimeException); assertException(serializableException, blankRuntimeException); }