Java 在Junit测试期间,如何在AEM中调整component.json时测试条件是否为null?
我想知道,对于我的junit测试,是否可以将以下if条件测试为null 以下是AEM模型的实施:Java 在Junit测试期间,如何在AEM中调整component.json时测试条件是否为null?,java,aem,junit5,Java,Aem,Junit5,我想知道,对于我的junit测试,是否可以将以下if条件测试为null 以下是AEM模型的实施: int currentYear = 0; @PostConstruct public void setup() { String lmStr = ""; Calendar lm= currentPage.getLastModified(); if(lm!=null){ <= I would like to know if it is possible
int currentYear = 0;
@PostConstruct
public void setup() {
String lmStr = "";
Calendar lm= currentPage.getLastModified();
if(lm!=null){ <= I would like to know if it is possible to test for the null condition
DateFormat df = new SimpleDateFormat("DD_MMM_YYYY");
lmStr = df.format(lm.getTime());
}
//Gets the current year for copyright
currentYear = Calendar.getInstance().get(Calendar.YEAR);
}
{
"jcr:primaryType": "cq:Page",
"jcr:createdBy": "admin",
"jcr:created": "Wed Jul 10 2019 17:28:17 GMT+0800",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:mixinTypes": [
"mix:versionable"
],
"jcr:createdBy": "admin",
"jcr:title": "Page Title",
"cq:lastReplicationAction": "Activate",
"jcr:versionHistory": "ddd-eee-fff",
"cq:template": "/conf/project/templates/some-template",
"cq:lastReplicatedBy": "some-service",
"jcr:predecessors": [
"aaa-bbb-ccc"
],
"jcr:created": "Wed Jul 10 2019 17:28:17 GMT+0800",
"cq:lastReplicated": "Mon Sep 30 2019 17:37:26 GMT+0800",
"cq:lastModified": "null", <= I tried putting null here instead of the date but it's not working
"jcr:description": "Description",
...
int currentYear=0;
@施工后
公共作废设置(){
字符串lmStr=“”;
Calendar lm=currentPage.getLastModified();
如果(lm!=null){根据注释
JcrConstants.JCR_UUID,JcrConstants.JCR_基本版本,JcrConstants.JCR_前辈,JcrConstants.JCR_后辈,JcrConstants.JCR_创建,JcrConstants.JCR_版本历史,“JCR:checkedOut”,“JCR:isCheckedOut”,“rep:policy”
根据评论,所有这些都是不可变的
JcrConstants.JCR_UUID,JcrConstants.JCR_基本版本,JcrConstants.JCR_前辈,JcrConstants.JCR_后辈,JcrConstants.JCR_创建,JcrConstants.JCR_版本历史,“JCR:checkedOut”,“JCR:isCheckedOut”,“rep:policy”
所有这些都是不可变的使用mockito模拟currentPage的abt是什么?当键“cq:lastModified”被删除时,你会得到什么?它会抛出NullPointerException使用mockito模拟currentPage的abt是什么?当键“cq:lastModified”被删除时,你会得到什么?它会抛出NullPointerException