@Test
public void testAllocateIdArray() {
KeyFactory keyFactory = datastore.newKeyFactory().setKind(KIND1);
IncompleteKey incompleteKey1 = keyFactory.newKey();
IncompleteKey incompleteKey2 =
keyFactory.setKind(KIND2).addAncestor(PathElement.of(KIND1, 10)).newKey();
Key key3 = keyFactory.newKey("name");
List<Key> result1 = datastore.allocateId(incompleteKey1, incompleteKey2, incompleteKey1);
assertEquals(3, result1.size());
assertEquals(Key.newBuilder(incompleteKey1, result1.get(0).getId()).build(), result1.get(0));
assertEquals(Key.newBuilder(incompleteKey1, result1.get(2).getId()).build(), result1.get(2));
assertEquals(Key.newBuilder(incompleteKey2, result1.get(1).getId()).build(), result1.get(1));
try {
datastore.allocateId(incompleteKey1, incompleteKey2, key3);
fail("expecting a failure");
} catch (IllegalArgumentException expected) {
assertEquals(expected.getMessage(), "keys must be IncompleteKey instances");
}
}