Java Code Examples for com.google.appengine.api.datastore.KeyRange#getStart()
The following examples show how to use
com.google.appengine.api.datastore.KeyRange#getStart() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AllocateIdsTest.java From appengine-tck with Apache License 2.0 | 6 votes |
@Test public void testOutOfRangeEntity() throws Exception { final long allocateNum = 5; // Range default namespace KeyRange range = service.allocateIds(ALLOCATE_IDS_ENTITY, allocateNum); Entity noParent = createTestEntity(ALLOCATE_IDS_ENTITY); assertEntityNotInRange(noParent, range); // Range with specified parent Entity parent = new Entity(ALLOCATE_IDS_ENTITY); Key parentKey = service.put(parent); KeyRange range2 = service.allocateIds(parentKey, ALLOCATE_IDS_ENTITY, allocateNum); Entity entity = createTestEntity(ALLOCATE_IDS_ENTITY, parentKey); assertEntityNotInRange(entity, range2); // In Range entity should have same parent Entity child = new Entity(range2.getStart()); Key childKey = service.put(child); // child with allocated key should have correct parent. Assert.assertEquals(parentKey, childKey.getParent()); }
Example 2
Source File: AllocateIdsTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test public void testAllocateChild() { Entity parent = new Entity(ALLOCATE_IDS_ENTITY); parent.setProperty("name", "parent-" + System.currentTimeMillis()); Key parentKey = service.put(parent); final int allocateSize = 10; KeyRange range = service.allocateIds(parentKey, ALLOCATE_IDS_ENTITY, allocateSize); Entity child = new Entity(range.getStart()); Key key = service.put(child); // child with allocated key should have correct parent. Assert.assertEquals(parentKey, key.getParent()); }
Example 3
Source File: AsyncServiceTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test public void testDataAllocate() throws Exception { final long allocateNum = 5; // Range default namespace Future<KeyRange> futureRange = asyncService.allocateIds(ASYNC_ENTITY, allocateNum); KeyRange range = futureRange.get(); assertTaskIsDoneAndNotCancelled(futureRange); Entity noParent = createTestEntity(ASYNC_ENTITY); assertEntityNotInRange(noParent, range); // Range with specified parent Entity parent = new Entity(ASYNC_ENTITY); parent.setProperty("name", "parent" + new Date()); Key parentKey = service.put(parent); Future<KeyRange> futureRange2 = asyncService.allocateIds(parentKey, ASYNC_ENTITY, allocateNum); KeyRange range2 = futureRange2.get(); assertTaskIsDoneAndNotCancelled(futureRange2); Entity noParent2 = createTestEntity(ASYNC_ENTITY, parentKey); assertEntityNotInRange(noParent2, range2); // In Range entity should have same parent Entity child = new Entity(range2.getStart()); child.setProperty("name", "second" + new Date()); Key childKey = service.put(child); // child with allocated key should have correct parent. assertEquals(parentKey, childKey.getParent()); }