@isTest
|
public class monitorUpdateESignBatchTest {
|
// 方法1:测试没有签收单的计划作业
|
static testMethod void testMethod1() {
|
Database.executeBatch(new monitorUpdateESignBatch(), 1);
|
}
|
// 方法2:测试有签收单的计划作业
|
static testMethod void testMethod2() {
|
ScBean scB;
|
scB = monitorUpdateESignBatchTest.setSc('updateESignFormSchedule', 9, 23, 0, '0 30 2', null);
|
system.schedule(scB.scName, scB.scTime, new updateESignFormSchedule());
|
|
Database.executeBatch(new monitorUpdateESignBatch(), 1);
|
}
|
// 方法3:提高覆盖率
|
static testMethod void testMethod3() {
|
monitorUpdateESignBatch mues = new monitorUpdateESignBatch();
|
mues.likeStr = 'updateESignFormSchedule00%';
|
mues.tempLikeStr = 'updateESignFormSchedule00%';
|
}
|
|
|
public static ScBean setSc(String baseName, Integer minhour, Integer maxhour, Integer minMin, String spbefore, String spafter) {
|
Datetime dt = Datetime.now();
|
Integer year = Integer.valueOf(dt.format('YYYY'));
|
Integer month = Integer.valueOf(dt.format('MM'));
|
Integer day = Integer.valueOf(dt.format('dd'));
|
Integer hour = Integer.valueOf(dt.format('HH'));
|
Integer min = Integer.valueOf(dt.format('mm'));
|
ScBean b = new ScBean();
|
if (hour == maxhour && min >= (minMin + 45)) {
|
b.scName = baseName + '001';
|
if (spafter != null && String.isNotBlank(spafter)) {
|
b.scName = baseName + '005';
|
b.scTime = spafter + ' ' + day + ' ' + month + ' ? ' + year;
|
// system.schedule(sJobame,spafter + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
|
return b;
|
} else {
|
dt = Datetime.now().addDays(1);
|
year = Integer.valueOf(dt.format('YYYY'));
|
month = Integer.valueOf(dt.format('MM'));
|
day = Integer.valueOf(dt.format('dd'));
|
hour = Integer.valueOf(dt.format('HH'));
|
min = Integer.valueOf(dt.format('mm'));
|
if (spbefore != null && String.isNotBlank(spbefore)) {
|
b.scName = baseName + '006';
|
// '0 20 8
|
b.scTime = spbefore + ' ' + day + ' ' + month + ' ? ' + year;
|
// system.schedule(sJobame,spbefore + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
|
} else {
|
b.scTime = '0 ' + minMin + ' ' + minhour + ' ' + day + ' ' + month + ' ? ' + year;
|
// system.schedule(sJobame,'0 ' + minMin + ' ' + minhour + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
|
}
|
}
|
} else if (min < minMin) {
|
b.scName = baseName + '001';
|
b.scTime = '0 ' + minMin + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year;
|
// system.schedule(sJobame,'0 ' + minMin + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
|
} else if (min < minMin + 15) {
|
b.scName = baseName + '002';
|
b.scTime = '0 ' + (minMin + 15) + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year;
|
// system.schedule(sJobame,'0 ' + (minMin + 15) + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
|
} else if (min < minMin + 30) {
|
b.scName = baseName + '003';
|
b.scTime = '0 ' + (minMin + 30) + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year;
|
// system.schedule(sJobame,'0 ' + (minMin + 30) + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
|
} else if (min < minMin + 45) {
|
b.scName = baseName + '004';
|
b.scTime = '0 ' + (minMin + 45) + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year;
|
// system.schedule(sJobame,'0 ' + (minMin + 45) + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
|
} else {
|
b.scName = baseName + '001';
|
b.scTime = '0 ' + minMin + ' ' + (hour + 1) + ' ' + day + ' ' + month + ' ? ' + year;
|
// system.schedule(sJobame,'0 ' + minMin + ' ' + (hour + 1) +' ' + day + ' ' + month + ' ? ' + year, new AgencyShareUpdateBatchSchedule());
|
|
}
|
return b;
|
}
|
//定时跑任务
|
public Class ScBean {
|
public String scName;
|
public String scTime;
|
}
|
}
|