奇怪的JUnit/Google端点测试结果
Strange JUnit/Google Endpoint test result
我有以下测试方法来测试在 Objectify 数据存储中创建合作伙伴实体。
我得到了异常的 DuplicateRecordException,但是当我尝试检索实体(Class 中的任何实体)时,我得到了一个 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());
}
}
}
解决了!
我也有这个:
new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(100)
我将 100 更改为 1,它起作用了。
我有以下测试方法来测试在 Objectify 数据存储中创建合作伙伴实体。
我得到了异常的 DuplicateRecordException,但是当我尝试检索实体(Class 中的任何实体)时,我得到了一个 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());
}
}
}
解决了!
我也有这个:
new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(100)
我将 100 更改为 1,它起作用了。