【发布时间】:2016-11-04 11:05:09
【问题描述】:
我有以下测试方法来测试在 Objectify 数据存储中创建合作伙伴实体。
我得到了异常的 DuplicateRecordException,但是当我尝试检索实体(该类中的任何实体)时,我得到了一个空值。知道我错过了什么吗?
注意:我启动了本地 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());
}
}
}
【问题讨论】:
标签: java google-app-engine android-studio junit objectify