private void testJsonMarshalling(final List<Video> videos) throws Exception {
    final JsonPath json = toJson(populateJaxbVideos(new JaxbVideosJson(), videos));

    // test generated json
    assertEquals(0, json.getInt("start"));
    assertEquals(videos.size(), json.getInt("limit"));
    assertEquals(videos.size() * 2, json.getInt("total"));

    // test for videos in the generated json
    assertTrue("videos is not an array", json.get("videos") instanceof List);
    assertEquals(videos.size(), json.getInt("videos.size()"));
    for (int i = 0; i < videos.size(); i++) {
      final String base = "videos[" + Integer.valueOf(i).toString() + "]";
      final Video video = videos.get(i);
      assertEquals(video.getId(), json.getLong(base + ".id"));
    }
  }
  @Test
  public void testXmlMarshalling() throws Exception {
    // generate xml for multiple videos
    final List<Video> videos = generateVideos();
    final XmlPath xml = toXml(populateJaxbVideos(new JaxbVideosXml(), videos));

    // test generated xml
    assertEquals("videos", xml.getString("videos.name()"));
    assertEquals(0, xml.getInt("videos.@start"));
    assertEquals(videos.size(), xml.getInt("videos.@limit"));
    assertEquals(videos.size() * 2, xml.getInt("videos.@total"));

    // test for videos in the generated xml
    assertEquals(videos.size(), xml.getInt("videos.video.size()"));
    for (int i = 0; i < videos.size(); i++) {
      final String base = "videos.video[" + Integer.valueOf(i).toString() + "]";
      final Video video = videos.get(i);
      assertEquals(video.getId(), xml.getLong(base + ".@id"));
    }
  }
  @GET
  @Path("thumbnail")
  public Response getThumbnail(@Context final MessageContext cxt, @Context final UriInfo uri) {
    // validate the session
    final Session session = this.getSession(cxt, uri);
    if (session == null || session.isExpired()) {
      return this.unauthorized(cxt, uri).build();
    }

    // get the video
    final Video video = this.getVideo(uri, session.getGuid());
    if (video != null) {
      final URL thumbUrl = this.awsController.getSignedUrl(video.getThumbnail());
      if (thumbUrl != null) {
        try {
          return ResponseUtils.temporaryRedirect(thumbUrl.toURI()).build();
        } catch (final Exception ignored) {
        }
      }
    }

    return Response.status(Status.NOT_FOUND).build();
  }