### Question:
ParseStreamManagement { public static Enabled enabled(XmlPullParser parser) throws XmlPullParserException, IOException { ParserUtils.assertAtStartTag(parser); boolean resume = ParserUtils.getBooleanAttribute(parser, "resume", false); String id = parser.getAttributeValue("", "id"); String location = parser.getAttributeValue("", "location"); int max = ParserUtils.getIntegerAttribute(parser, "max", -1); parser.next(); ParserUtils.assertAtEndTag(parser); return new Enabled(id, resume, location, max); }  static Enabled enabled(XmlPullParser parser); static Failed failed(XmlPullParser parser); static Resumed resumed(XmlPullParser parser); static AckAnswer ackAnswer(XmlPullParser parser); static AckRequest ackRequest(XmlPullParser parser);  }### Answer:
@Test public void testParseEnabled() throws Exception { String stanzaID = "zid615d9"; boolean resume = true; String location = "test"; int max = 42; String enabledStanza = XMLBuilder.create("enabled") .a("xmlns", "urn:xmpp:sm:3") .a("id", "zid615d9") .a("resume", String.valueOf(resume)) .a("location", location) .a("max", String.valueOf(max)) .asString(outputProperties); StreamManagement.Enabled enabledPacket = ParseStreamManagement.enabled( PacketParserUtils.getParserFor(enabledStanza)); assertNotNull(enabledPacket); assertEquals(enabledPacket.getId(), stanzaID); assertEquals(location, enabledPacket.getLocation()); assertEquals(resume, enabledPacket.isResumeSet()); assertEquals(max, enabledPacket.getMaxResumptionTime()); }
@Test public void testParseEnabledInvariant() throws XmlPullParserException, IOException { String enabledString = new StreamManagement.Enabled("stream-id", false).toXML().toString(); XmlPullParser parser = PacketParserUtils.getParserFor(enabledString); StreamManagement.Enabled enabled = ParseStreamManagement.enabled(parser); assertEquals(enabledString, enabled.toXML().toString()); }