@Test
public void testPostEntities() throws Exception {

  TimelineEntities entities = new TimelineEntities();
  TimelineEntity entity = new TimelineEntity();
  entity.setEntityId("test id 1");
  entity.setEntityType("test type 1");
  entity.setStartTime(System.currentTimeMillis());
  entity.setDomainId("domain_id_1");
  entities.addEntity(entity);
  WebResource r = resource();
  // No owner, will be rejected
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .accept(MediaType.APPLICATION_JSON)
      .type(MediaType.APPLICATION_JSON)
      .post(ClientResponse.class, entities);
  assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
      response.getType().toString());
  assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo());
  response = r.path("ws").path("v1").path("timeline")
      .queryParam("user.name", "tester")
      .accept(MediaType.APPLICATION_JSON)
      .type(MediaType.APPLICATION_JSON)
      .post(ClientResponse.class, entities);
  assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
      response.getType().toString());
  TimelinePutResponse putResposne =
      response.getEntity(TimelinePutResponse.class);
  Assert.assertNotNull(putResposne);
  Assert.assertEquals(0, putResposne.getErrors().size());
  // verify the entity exists in the store
  response = r.path("ws").path("v1").path("timeline")
      .path("test type 1").path("test id 1")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
      response.getType().toString());
  entity = response.getEntity(TimelineEntity.class);
  Assert.assertNotNull(entity);
  Assert.assertEquals("test id 1", entity.getEntityId());
  Assert.assertEquals("test type 1", entity.getEntityType());
}