MediaSegments { public static MediaSegments fromXml(String mediaSegmentsXml) throws JAXBException { StringReader sr = new StringReader(mediaSegmentsXml); JAXBContext jctx = JAXBContext.newInstance(MediaSegments.class); Unmarshaller unmarshaller = jctx.createUnmarshaller(); MediaSegments mediaSegments = (MediaSegments) unmarshaller.unmarshal(sr); sr.close(); return mediaSegments; } MediaSegments();  MediaSegments(String trackId, String filePath, List<MediaSegment> mediaSegments); List<MediaSegment> getMediaSegments(); String getTrackId(); String getFilePath(); String toXml(); static MediaSegments fromXml(String mediaSegmentsXml);  }
@Test public void testFromXml() throws Exception { assertNotNull(mediaSegments); String xml = mediaSegments.toXml(); MediaSegments mediaSegments = MediaSegments.fromXml(xml); assertNotNull(mediaSegments); assertNotNull(mediaSegments.getMediaSegments()); assertTrue(mediaSegments.getMediaSegments().size() == 3); }