1
私は客観により管理オブジェクトストアの整合性をテストするためのテストケースを書いた:イテレータは同じIDを持つ2つのレコードを取得しました...それはどのように可能ですか?
@Test
public void testCreateDuplicateWithDiffID() throws NullValueException, NotFoundException {
gift.setGiftedOn(Calendar.getInstance().getTime());
gEndPt.create(gift);
int countBefore2ndCreate = OfyController.count(Gift.class);
// reinitialize the instanceID of the gift...now it's "different"
gift.initID();
// got to make sure we have a new date
gift.setGiftedOn(Calendar.getInstance().getTime());
// attempt to "re-create" the same instance
gEndPt.create(gift);
int countAfterCreate = OfyController.count(Gift.class);
// check the count...make sure it changes after the two inserts
assertThat("New Gift was NOT created", countAfterCreate, is(2));
QueryResultIterator<Gift> iterator = OfyController.ofy().load().type(Gift.class).iterator();
while (iterator.hasNext()){
log.info(iterator.next().getInstID());
}
}
をすべてはwhileループまでの罰金です。いくつかの奇妙な理由で、イテレータは、同じレコードが表示されている(はそれだけを反復処理ではないですか、同じレコードを二回作成されたかわからない)