@Test
public void testMetadataDeserialization() throws Exception {

  Entity metadata = Entity.newBuilder(sessionKey)
      .set(SessionMetadata.MAX_INACTIVE_INTERVAL, 0)
      .set(SessionMetadata.CREATION_TIME, 1)
      .set(SessionMetadata.LAST_ACCESSED_TIME, 2)
      .set(SessionMetadata.IS_NEW, true)
      .set(SessionMetadata.IS_VALID, true)
      .set(SessionMetadata.THIS_ACCESSED_TIME, 3)
      .build();
  DatastoreSession session = new DatastoreSession(sessionManager);
  session.restoreFromEntities(sessionKey, Collections.singleton(metadata));
  assertEquals(session.getMaxInactiveInterval(), 0);
  assertEquals(session.getCreationTime(), 1);
  assertEquals(session.getLastAccessedTime(), 2);
  assertEquals(session.isNew(), true);
  assertEquals(session.isValid(), true);
  assertEquals(session.getThisAccessedTime(), 3);
}