|
|
|
@ -27,7 +27,6 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
|
|
|
|
|
@Inject TaskService taskService;
|
|
|
|
|
@Inject TagService tagService;
|
|
|
|
|
@Inject MetadataService metadataService;
|
|
|
|
|
@Inject Preferences preferences;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -156,7 +155,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
private void insertTitleAddTask(String title, Task task) {
|
|
|
|
|
task.clear();
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -167,7 +166,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
|
|
|
|
|
String title = "Jog today";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
Date date = newDate(task.getDueDate());
|
|
|
|
|
assertEquals(date.getDay()+1, today.get(Calendar.DAY_OF_WEEK));
|
|
|
|
|
//Calendar starts 1-6, date.getDay() starts at 0
|
|
|
|
@ -175,7 +174,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
task = new Task();
|
|
|
|
|
title = "Jog tomorrow";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
date = newDate(task.getDueDate());
|
|
|
|
|
assertEquals((date.getDay()+1) % 7, (today.get(Calendar.DAY_OF_WEEK)+1) % 7);
|
|
|
|
|
|
|
|
|
@ -202,14 +201,14 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
task = new Task();
|
|
|
|
|
title = "Jog "+ days[i];
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
date = newDate(task.getDueDate());
|
|
|
|
|
assertEquals(date.getDay(), i);
|
|
|
|
|
|
|
|
|
|
task = new Task();
|
|
|
|
|
title = "Jog "+ abrevDays[i];
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
date = newDate(task.getDueDate());
|
|
|
|
|
assertEquals(date.getDay(), i);
|
|
|
|
|
}
|
|
|
|
@ -233,14 +232,14 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
task = new Task();
|
|
|
|
|
String title = "Jog " + acceptedString;
|
|
|
|
|
task.setTitle(title); //test at end of task. should set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals((int)task.getImportance(), Task.IMPORTANCE_LEAST);
|
|
|
|
|
}
|
|
|
|
|
for (String acceptedString:acceptedStrings){
|
|
|
|
|
task = new Task();
|
|
|
|
|
String title = acceptedString + " jog";
|
|
|
|
|
task.setTitle(title); //test at beginning of task. should not set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertNotSame(task.getImportance(),Task.IMPORTANCE_LEAST);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -297,25 +296,25 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
task = new Task();
|
|
|
|
|
String title = "Jog " + acceptedStringAtEnd;
|
|
|
|
|
task.setTitle(title); //test at end of task. should set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals((int)task.getImportance(), Task.IMPORTANCE_MUST_DO);
|
|
|
|
|
|
|
|
|
|
task = new Task();
|
|
|
|
|
title = acceptedStringAtEnd + " jog";
|
|
|
|
|
task.setTitle(title); //test at beginning of task. should not set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertNotSame(task.getImportance(), Task.IMPORTANCE_MUST_DO);
|
|
|
|
|
}
|
|
|
|
|
for (String acceptedStringAnywhere:acceptedStringsAnywhere){
|
|
|
|
|
task = new Task();
|
|
|
|
|
String title = "Jog " + acceptedStringAnywhere;
|
|
|
|
|
task.setTitle(title); //test at end of task. should set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals((int)task.getImportance(), Task.IMPORTANCE_MUST_DO);
|
|
|
|
|
|
|
|
|
|
title = acceptedStringAnywhere + " jog";
|
|
|
|
|
task.setTitle(title); //test at beginning of task. should set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals((int)task.getImportance(), Task.IMPORTANCE_MUST_DO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -339,25 +338,25 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
task = new Task();
|
|
|
|
|
String title = "Jog " + acceptedStringAtEnd;
|
|
|
|
|
task.setTitle(title); //test at end of task. should set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals((int)task.getImportance(), Task.IMPORTANCE_DO_OR_DIE);
|
|
|
|
|
|
|
|
|
|
task = new Task();
|
|
|
|
|
title = acceptedStringAtEnd + " jog";
|
|
|
|
|
task.setTitle(title); //test at beginning of task. should not set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertNotSame(task.getImportance(), Task.IMPORTANCE_DO_OR_DIE);
|
|
|
|
|
}
|
|
|
|
|
for (String acceptedStringAnywhere:acceptedStringsAnywhere){
|
|
|
|
|
task = new Task();
|
|
|
|
|
String title = "Jog " + acceptedStringAnywhere;
|
|
|
|
|
task.setTitle(title); //test at end of task. should set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals((int)task.getImportance(), Task.IMPORTANCE_DO_OR_DIE);
|
|
|
|
|
|
|
|
|
|
title = acceptedStringAnywhere + " jog";
|
|
|
|
|
task.setTitle(title); //test at beginning of task. should set importance.
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals((int)task.getImportance(), Task.IMPORTANCE_DO_OR_DIE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -373,7 +372,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
String title = "Jog daily";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
RRule rrule = new RRule();
|
|
|
|
|
rrule.setFreq(Frequency.DAILY);
|
|
|
|
|
rrule.setInterval(1);
|
|
|
|
@ -383,7 +382,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
|
|
|
|
|
title = "Jog every day";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertFalse(task.hasDueTime());
|
|
|
|
|
assertFalse(task.hasDueDate());
|
|
|
|
@ -392,7 +391,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
title = "Jog every " + i + " days.";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
rrule.setInterval(i);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertFalse(task.hasDueTime());
|
|
|
|
|
assertFalse(task.hasDueDate());
|
|
|
|
@ -406,7 +405,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
String title = "Jog weekly";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
RRule rrule = new RRule();
|
|
|
|
|
rrule.setFreq(Frequency.WEEKLY);
|
|
|
|
|
rrule.setInterval(1);
|
|
|
|
@ -416,7 +415,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
|
|
|
|
|
title = "Jog every week";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertFalse(task.hasDueTime());
|
|
|
|
|
assertFalse(task.hasDueDate());
|
|
|
|
@ -425,7 +424,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
title = "Jog every " + i + " weeks";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
rrule.setInterval(i);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertFalse(task.hasDueTime());
|
|
|
|
|
assertFalse(task.hasDueDate());
|
|
|
|
@ -438,7 +437,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
String title = "Jog monthly";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
RRule rrule = new RRule();
|
|
|
|
|
rrule.setFreq(Frequency.MONTHLY);
|
|
|
|
|
rrule.setInterval(1);
|
|
|
|
@ -448,7 +447,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
|
|
|
|
|
title = "Jog every month";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertFalse(task.hasDueTime());
|
|
|
|
|
assertFalse(task.hasDueDate());
|
|
|
|
@ -457,7 +456,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
title = "Jog every " + i + " months";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
rrule.setInterval(i);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertFalse(task.hasDueTime());
|
|
|
|
|
assertFalse(task.hasDueDate());
|
|
|
|
@ -469,7 +468,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
String title = "Jog daily starting from today";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
RRule rrule = new RRule();
|
|
|
|
|
rrule.setFreq(Frequency.DAILY);
|
|
|
|
|
rrule.setInterval(1);
|
|
|
|
@ -480,7 +479,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
task.clearValue(Task.UUID);
|
|
|
|
|
title = "Jog every day starting from today";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertTrue(task.hasDueDate());
|
|
|
|
|
|
|
|
|
@ -488,7 +487,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
title = "Jog every " + i + " days starting from today";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
rrule.setInterval(i);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertTrue(task.hasDueDate());
|
|
|
|
|
task = new Task();
|
|
|
|
@ -499,7 +498,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
String title = "Jog weekly starting from today";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
RRule rrule = new RRule();
|
|
|
|
|
rrule.setFreq(Frequency.WEEKLY);
|
|
|
|
|
rrule.setInterval(1);
|
|
|
|
@ -510,7 +509,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
task.clearValue(Task.UUID);
|
|
|
|
|
title = "Jog every week starting from today";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertTrue(task.hasDueDate());
|
|
|
|
|
|
|
|
|
@ -518,7 +517,7 @@ public class TitleParserTest extends DatabaseTestCase {
|
|
|
|
|
title = "Jog every " + i + " weeks starting from today";
|
|
|
|
|
task.setTitle(title);
|
|
|
|
|
rrule.setInterval(i);
|
|
|
|
|
TaskService.createWithValues(taskService, metadataService, tagService, task, null, title);
|
|
|
|
|
taskService.createWithValues(task, null, title);
|
|
|
|
|
assertEquals(task.getRecurrence(), rrule.toIcal());
|
|
|
|
|
assertTrue(task.hasDueDate());
|
|
|
|
|
task = new Task();
|
|
|
|
|