@Test public void parse() { SessionsIQ element = parseString(stanza); assertNotNull(element); assertEquals(2, element.getSessions().size()); Session session1 = element.getSessions().get(0); assertNotNull(session1); assertEquals("xabber-web 2.3", session1.getClient()); assertEquals("iMac Pro MacOS 10.14", session1.getDevice()); assertEquals("024717297867c1d32714cadde305825a9909ef7c", session1.getUid()); assertEquals("127.0.0.1", session1.getIp()); assertEquals(1636322632000L, session1.getExpire()); assertEquals(1536322632000L, session1.getLastAuth()); Session session2 = element.getSessions().get(1); assertNotNull(session2); assertEquals("xabber-android 2.363", session2.getClient()); assertEquals("Nokia Android 8.0", session2.getDevice()); assertEquals("7dbf8541c4de1d24a0f748cc01f98a140100979a", session2.getUid()); assertEquals("127.0.1.1", session2.getIp()); assertEquals(1736322632000L, session2.getExpire()); assertEquals(1436322632000L, session2.getLastAuth()); }
@Override public SessionsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { List<Session> sessions = new ArrayList<>(); outerloop: while (true) { int eventType = parser.getEventType(); switch (eventType) { case XmlPullParser.START_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName()) && SessionsIQ.NAMESPACE.equals(parser.getNamespace())) { parser.next(); } else if (Session.ELEMENT.equals(parser.getName())) { Session session = parseSession(parser); if (session != null) sessions.add(session); parser.next(); } break; case XmlPullParser.END_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName())) { break outerloop; } else parser.next(); break; default: parser.next(); } } if (!sessions.isEmpty()) return new SessionsIQ(sessions); else return null; }
SessionsProvider extends IQProvider<SessionsIQ> { @Override public SessionsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { List<Session> sessions = new ArrayList<>(); outerloop: while (true) { int eventType = parser.getEventType(); switch (eventType) { case XmlPullParser.START_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName()) && SessionsIQ.NAMESPACE.equals(parser.getNamespace())) { parser.next(); } else if (Session.ELEMENT.equals(parser.getName())) { Session session = parseSession(parser); if (session != null) sessions.add(session); parser.next(); } break; case XmlPullParser.END_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName())) { break outerloop; } else parser.next(); break; default: parser.next(); } } if (!sessions.isEmpty()) return new SessionsIQ(sessions); else return null; } }
SessionsProvider extends IQProvider<SessionsIQ> { @Override public SessionsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { List<Session> sessions = new ArrayList<>(); outerloop: while (true) { int eventType = parser.getEventType(); switch (eventType) { case XmlPullParser.START_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName()) && SessionsIQ.NAMESPACE.equals(parser.getNamespace())) { parser.next(); } else if (Session.ELEMENT.equals(parser.getName())) { Session session = parseSession(parser); if (session != null) sessions.add(session); parser.next(); } break; case XmlPullParser.END_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName())) { break outerloop; } else parser.next(); break; default: parser.next(); } } if (!sessions.isEmpty()) return new SessionsIQ(sessions); else return null; }  }
SessionsProvider extends IQProvider<SessionsIQ> { @Override public SessionsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { List<Session> sessions = new ArrayList<>(); outerloop: while (true) { int eventType = parser.getEventType(); switch (eventType) { case XmlPullParser.START_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName()) && SessionsIQ.NAMESPACE.equals(parser.getNamespace())) { parser.next(); } else if (Session.ELEMENT.equals(parser.getName())) { Session session = parseSession(parser); if (session != null) sessions.add(session); parser.next(); } break; case XmlPullParser.END_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName())) { break outerloop; } else parser.next(); break; default: parser.next(); } } if (!sessions.isEmpty()) return new SessionsIQ(sessions); else return null; }  @Override SessionsIQ parse(XmlPullParser parser, int initialDepth); }
SessionsProvider extends IQProvider<SessionsIQ> { @Override public SessionsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { List<Session> sessions = new ArrayList<>(); outerloop: while (true) { int eventType = parser.getEventType(); switch (eventType) { case XmlPullParser.START_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName()) && SessionsIQ.NAMESPACE.equals(parser.getNamespace())) { parser.next(); } else if (Session.ELEMENT.equals(parser.getName())) { Session session = parseSession(parser); if (session != null) sessions.add(session); parser.next(); } break; case XmlPullParser.END_TAG: if (SessionsIQ.ELEMENT.equals(parser.getName())) { break outerloop; } else parser.next(); break; default: parser.next(); } } if (!sessions.isEmpty()) return new SessionsIQ(sessions); else return null; }  @Override SessionsIQ parse(XmlPullParser parser, int initialDepth);  }