@Test
public void prepareVastVideoConfiguration_shouldHandleMultipleRedirects() throws Exception {

    // Vast redirect responses
    mFakeHttpLayer.addPendingHttpResponse(200, TEST_VAST_XML_STRING);
    mFakeHttpLayer.addPendingHttpResponse(200, TEST_VAST_XML_STRING);
    mFakeHttpLayer.addPendingHttpResponse(200, TEST_NESTED_VAST_XML_STRING);
    // Video download response
    mFakeHttpLayer.addPendingHttpResponse(200, "video_data");
    prepareVastVideoConfiguration();
    semaphore.acquire();
    verify(vastManagerListener).onVastVideoConfigurationPrepared(any(VastVideoConfiguration.class));
    // at this point it should have 3 sets of data from TEST_VAST_XML_STRING and one set from TEST_NESTED_VAST_XML_STRING
    assertThat(vastVideoConfiguration.getNetworkMediaFileUrl()).isEqualTo("https://s3.amazonaws.com/mopub-vast/tapad-video.mp4");
    final String expectedFilePathDiskCache = CacheService.getFilePathDiskCache(vastVideoConfiguration.getNetworkMediaFileUrl());
    assertThat(vastVideoConfiguration.getDiskMediaFileUrl()).isEqualTo(expectedFilePathDiskCache);
    assertThat(vastVideoConfiguration.getClickThroughUrl()).isEqualTo("http://rtb-test.dev.tapad.com:8080/click?ta_pinfo=JnRhX2JpZD1iNDczNTQwMS1lZjJkLTExZTItYTNkNS0yMjAwMGE4YzEwOWQmaXA9OTguMTE2LjEyLjk0JnNzcD1MSVZFUkFJTCZ0YV9iaWRkZXJfaWQ9NTEzJTNBMzA1NSZjdHg9MTMzMSZ0YV9jYW1wYWlnbl9pZD01MTMmZGM9MTAwMjAwMzAyOSZ1YT1Nb3ppbGxhJTJGNS4wKyUyOE1hY2ludG9zaCUzQitJbnRlbCtNYWMrT1MrWCsxMF84XzMlMjkrQXBwbGVXZWJLaXQlMkY1MzcuMzYrJTI4S0hUTUwlMkMrbGlrZStHZWNrbyUyOStDaHJvbWUlMkYyNy4wLjE0NTMuMTE2K1NhZmFyaSUyRjUzNy4zNiZjcHQ9VkFTVCZkaWQ9ZDgyNWZjZDZlNzM0YTQ3ZTE0NWM4ZTkyNzMwMjYwNDY3YjY1NjllMSZpZD1iNDczNTQwMC1lZjJkLTExZTItYTNkNS0yMjAwMGE4YzEwOWQmcGlkPUNPTVBVVEVSJnN2aWQ9MSZicD0zNS4wMCZjdHhfdHlwZT1BJnRpZD0zMDU1JmNyaWQ9MzA3MzE%3D&crid=30731&ta_action_id=click&ts=1374099035458&redirect=http%3A%2F%2Ftapad.com");
    assertThat(vastVideoConfiguration.getImpressionTrackers().size()).isEqualTo(13);
    assertThat(vastVideoConfiguration.getStartTrackers().size()).isEqualTo(3);
    assertThat(vastVideoConfiguration.getFirstQuartileTrackers().size()).isEqualTo(3);
    assertThat(vastVideoConfiguration.getMidpointTrackers().size()).isEqualTo(3);
    assertThat(vastVideoConfiguration.getThirdQuartileTrackers().size()).isEqualTo(3);
    assertThat(vastVideoConfiguration.getCompleteTrackers().size()).isEqualTo(3);
    assertThat(vastVideoConfiguration.getClickTrackers().size()).isEqualTo(3);
    final VastCompanionAd vastCompanionAd = vastVideoConfiguration.getVastCompanionAd();
    assertThat(vastCompanionAd.getWidth()).isEqualTo(300);
    assertThat(vastCompanionAd.getHeight()).isEqualTo(250);
    assertThat(vastCompanionAd.getImageUrl()).isEqualTo("http://demo.tremormedia.com/proddev/vast/Blistex1.jpg");
    assertThat(vastCompanionAd.getClickThroughUrl()).isEqualTo("http://www.tremormedia.com");
    assertThat(vastCompanionAd.getClickTrackers())
            .containsOnly("http://myTrackingURL/firstCompanionCreativeView", "http://myTrackingURL/secondCompanionCreativeView");
}