@Test
public void testFromBase64EncodedPolicy() throws UnsupportedEncodingException {

  String examplePolicy = "{\"Statement\": {\"Resource\":\"http://mh-allinone/engage/url/to/resource.mp4\",\"Condition\":{\"DateLessThan\":1425170777000,\"DateGreaterThan\":1425084379000,\"IpAddress\": \"10.0.0.1\"}}}";
  Policy policy = PolicyUtils.fromBase64EncodedPolicy(PolicyUtils.base64Encode(examplePolicy));
  assertEquals("http://mh-allinone/engage/url/to/resource.mp4", policy.getBaseUrl());
  assertEquals(EXAMPLE_IP, policy.getClientIpAddress().get().getHostAddress());
  DateTime after = new DateTime(2015, 02, 28, 00, 46, 19, 0, DateTimeZone.UTC);
  after = after.withSecondOfMinute(19);
  assertEquals(after, policy.getValidFrom().get());
  DateTime before = new DateTime(2015, 03, 01, 00, 46, 17, 0, DateTimeZone.UTC);
  assertEquals(before, policy.getValidUntil());
}