### Question:
XmlFile { public static XmlFile of(ByteSource source) { return of(source, ""); } private  XmlFile(XmlElement root, Map<String, XmlElement> refs); static XmlFile of(ByteSource source); static XmlFile of(ByteSource source, String refAttrName); static XmlElement parseElements(ByteSource source, ToIntFunction<String> filterFn); XmlElement getRoot(); ImmutableMap<String, XmlElement> getReferences(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void test_of_ByteSource_mismatchedTags() { ByteSource source = ByteSource.wrap(SAMPLE_MISMATCHED_TAGS.getBytes(StandardCharsets.UTF_8)); assertThatIllegalArgumentException().isThrownBy(() -> XmlFile.of(source)); }
@Test public void test_of_ByteSource_badEnd() { ByteSource source = ByteSource.wrap(SAMPLE_BAD_END.getBytes(StandardCharsets.UTF_8)); assertThatIllegalArgumentException().isThrownBy(() -> XmlFile.of(source)); }
@Test public void test_of_ByteSource_ioException() { ByteSource source = Files.asByteSource(new File("/oh-dear-no-such-file")); assertThatExceptionOfType(UncheckedIOException.class).isThrownBy(() -> XmlFile.of(source)); }
@Test public void test_of_ByteSource_parsedReferences_ioException() { ByteSource source = Files.asByteSource(new File("/oh-dear-no-such-file")); assertThatExceptionOfType(UncheckedIOException.class).isThrownBy(() -> XmlFile.of(source, "key")); }