@Test public void marshallingFailsBeanValidation() throws Exception { final KeyDataConfig input = new KeyDataConfig(null, null); try (OutputStream bout = new ByteArrayOutputStream()) { JaxbUtil.marshal(input, bout); failBecauseExceptionWasNotThrown(ConstraintViolationException.class); } catch (ConstraintViolationException ex) { assertThat(ex).isInstanceOf(ConstraintViolationException.class); } }
public static void marshal(Object object, OutputStream outputStream) { try { MarshallerBuilder.create().build().marshal(object, outputStream); } catch (Throwable ex) { Optional<ConstraintViolationException> validationException = unwrapConstraintViolationException(ex); if (validationException.isPresent()) { throw validationException.get(); } throw new ConfigException(ex); } }
JaxbUtil { public static void marshal(Object object, OutputStream outputStream) { try { MarshallerBuilder.create().build().marshal(object, outputStream); } catch (Throwable ex) { Optional<ConstraintViolationException> validationException = unwrapConstraintViolationException(ex); if (validationException.isPresent()) { throw validationException.get(); } throw new ConfigException(ex); } } }
JaxbUtil { public static void marshal(Object object, OutputStream outputStream) { try { MarshallerBuilder.create().build().marshal(object, outputStream); } catch (Throwable ex) { Optional<ConstraintViolationException> validationException = unwrapConstraintViolationException(ex); if (validationException.isPresent()) { throw validationException.get(); } throw new ConfigException(ex); } } private  JaxbUtil(); }
JaxbUtil { public static void marshal(Object object, OutputStream outputStream) { try { MarshallerBuilder.create().build().marshal(object, outputStream); } catch (Throwable ex) { Optional<ConstraintViolationException> validationException = unwrapConstraintViolationException(ex); if (validationException.isPresent()) { throw validationException.get(); } throw new ConfigException(ex); } } private  JaxbUtil(); static T unmarshal(InputStream inputStream, Class<T> type); static void marshal(Object object, OutputStream outputStream); static void marshalWithNoValidation(Object object, OutputStream outputStream); static String marshalToString(Object object); static String marshalToStringNoValidation(Object object); static void marshalMasked(Config object, OutputStream outputStream); }
JaxbUtil { public static void marshal(Object object, OutputStream outputStream) { try { MarshallerBuilder.create().build().marshal(object, outputStream); } catch (Throwable ex) { Optional<ConstraintViolationException> validationException = unwrapConstraintViolationException(ex); if (validationException.isPresent()) { throw validationException.get(); } throw new ConfigException(ex); } } private  JaxbUtil(); static T unmarshal(InputStream inputStream, Class<T> type); static void marshal(Object object, OutputStream outputStream); static void marshalWithNoValidation(Object object, OutputStream outputStream); static String marshalToString(Object object); static String marshalToStringNoValidation(Object object); static void marshalMasked(Config object, OutputStream outputStream); static final Class[] JAXB_CLASSES; }