use of org.jivesoftware.smackx.mood.element.MoodElement in project Smack by igniterealtime.
the class MoodManagerTest method addMessageTest.
@Test
public void addMessageTest() {
Message message = StanzaBuilder.buildMessage().build();
MoodManager.addMoodToMessage(message, Mood.sad);
assertTrue(message.hasExtension(MoodElement.ELEMENT, MoodElement.NAMESPACE));
assertTrue(MoodElement.hasMoodElement(message));
MoodElement element = MoodElement.fromMessage(message);
assertNotNull(element);
assertEquals(Mood.sad, element.getMood());
assertFalse(element.hasConcretisation());
assertFalse(element.hasText());
message = StanzaBuilder.buildMessage().build();
MoodManager.addMoodToMessage(message, Mood.happy, new MoodConcretisationTest.EcstaticMoodConcretisation());
element = MoodElement.fromMessage(message);
assertTrue(element.hasConcretisation());
}
use of org.jivesoftware.smackx.mood.element.MoodElement in project Smack by igniterealtime.
the class MoodElementTest method toXmlTest.
@Test
public void toXmlTest() throws Exception {
String xml = "<mood xmlns='http://jabber.org/protocol/mood'>" + "<happy/>" + "<text>Yay, the mood spec has been approved!</text>" + "</mood>";
MoodElement moodElement = new MoodElement(new MoodElement.MoodSubjectElement(Mood.happy, null), "Yay, the mood spec has been approved!");
assertXmlSimilar(xml, moodElement.toXML().toString());
assertFalse(moodElement.hasConcretisation());
assertEquals(Mood.happy, moodElement.getMood());
XmlPullParser parser = TestUtils.getParser(xml);
MoodElement parsed = MoodProvider.INSTANCE.parse(parser);
assertEquals(xml, parsed.toXML().toString());
}
use of org.jivesoftware.smackx.mood.element.MoodElement in project Smack by igniterealtime.
the class MoodElementTest method emptyMoodTest.
@Test
public void emptyMoodTest() throws Exception {
MoodElement empty = new MoodElement(null, null);
assertNull(empty.getText());
assertNull(empty.getMood());
assertNull(empty.getMoodConcretisation());
assertFalse(empty.hasText());
assertFalse(empty.hasConcretisation());
String xml = "<mood xmlns='http://jabber.org/protocol/mood'/>";
XmlPullParser parser = TestUtils.getParser(xml);
MoodElement emptyParsed = MoodProvider.INSTANCE.parse(parser);
assertEquals(empty.toXML().toString(), emptyParsed.toXML().toString());
}
Aggregations