我有以下测试方法来测试在Objectify数据存储区中创建Partner实体。
我将DuplicateRecordException视为例外,但是当我尝试检索实体(该类中的任何实体)时,我得到了一个null。知道我错过了什么吗?
注意:我启动了本地API资源管理器来测试createPartner()方法,它很好。
@Test
public void testCreatePartner(){
try {
Partner p = createPartner(instID, displayName, new Text(aboutMe));
createPartner(instID, displayName, newText(aboutMe));
assertNull(p);
} catch (DuplicateRecordException | MissingIDException | FailToSaveRecordException e) {
//e.printStackTrace();
log.severe("======> "+e.getMessage());
Partner q = OfyController.ofy().load().type(Partner.class).first().now();
if (q!=null) {
log.info("------>>" + q.getDisplayName());
}
}
}
答案 0 :(得分:0)
解决了!
我也有这个:
new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(100)
我将100改为1并且有效。