### Question:
DiagramSource { public static String decode(String encoded) throws DecodeException { return decode(encoded, true); }  static String decode(String encoded); static String decode(String encoded, boolean trim); static String plantumlDecode(String source); static byte[] encode(String decoded);  }### Answer:
@Test void should_throw_when_source_is_not_utf8_encoded() { assertThatThrownBy(() -> DiagramSource.decode(new String(Base64.getDecoder().decode("gAID")))) .isInstanceOf(DecodeException.class) .hasMessageContaining("Unable to decode the source.") .hasCauseInstanceOf(IllegalArgumentException.class) .hasStackTraceContaining("java.lang.IllegalArgumentException: Illegal base64 character 3f"); }
@Test void should_throw_when_source_encoded_is_empty() { assertThatThrownBy(() -> DiagramSource.decode("")) .isInstanceOf(DecodeException.class) .hasMessageContaining("Unable to decode the source."); }
@Test void should_throw_when_source_encoded_is_null() { assertThatThrownBy(() -> DiagramSource.decode(null)) .isInstanceOf(DecodeException.class) .hasMessageContaining("Unable to decode the source."); }
@Test void should_throw_when_source_encoded_only_contains_spaces() { assertThatThrownBy(() -> DiagramSource.decode(" ")) .isInstanceOf(DecodeException.class) .hasMessageContaining("Unable to decode the source."); }
@Test void should_throw_when_source_encoded_is_invalid() { assertThatThrownBy(() -> DiagramSource.decode("abc")) .isInstanceOf(DecodeException.class) .hasMessageContaining("Unable to decode the source."); }