@Test
public void toXml() {

    UserMessageArchivePreferences preferences = new SimpleUserMessageArchivePreferences(
            DefaultUserArchiveBehaviour.ROSTER, Collections.singleton(EntityImpl.parseUnchecked("always@foo.com")),
            Collections.singleton(EntityImpl.parseUnchecked("never@foo.com")));
    XMLElement prefs = UserMessageArchivePreferencesElement.toXml("foo", preferences);
    assertEquals("prefs", prefs.getName());
    assertEquals("foo", prefs.getNamespaceURI());
    List<XMLElement> innerElements = prefs.getInnerElements();
    XMLElement always = innerElements.get(0);
    assertEquals("always", always.getName());
    List<XMLElement> alwaysJids = always.getInnerElements();
    assertEquals(1, alwaysJids.size());
    assertEquals("always@foo.com", alwaysJids.get(0).getInnerText().getText());
    XMLElement never = innerElements.get(1);
    assertEquals("never", never.getName());
    List<XMLElement> neverJids = never.getInnerElements();
    assertEquals(1, neverJids.size());
    assertEquals("never@foo.com", neverJids.get(0).getInnerText().getText());
}