@Test
public void testDecomposedSessionLoad() throws Exception {

  DatastoreSession session = new DatastoreSession(manager);
  session.setValid(true);
  session.setId(keyId);
  session.setAttribute("count", 2);
  session.setAttribute("map", Collections.singletonMap("key", "value"));
  KeyFactory attributeKeyFactory = datastore.newKeyFactory()
      .setKind("kind")
      .addAncestor(PathElement.of("kind", key.getName()));
  List<Entity> entities = session.saveToEntities(key, attributeKeyFactory);
  QueryResults<Entity> queryResults = new IteratorQueryResults<>(entities.iterator());
  when(datastore.<Entity>run(any())).thenReturn(queryResults);
  Session restored = store.load(keyId);
  assertEquals(keyId, restored.getId());
  assertEquals(2, restored.getSession().getAttribute("count"));
  assertEquals("value",
      ((Map<String, String>)session.getSession().getAttribute("map")).get("key"));
}