Fixed a bug with regexp title parsing, fixed compilation errors in gtasks tests

pull/14/head
Sam Bosley 13 years ago
parent 8f5f3def14
commit 933cfdf891

@ -12,7 +12,7 @@ import com.mdimension.jchronic.AstridChronic;
import com.mdimension.jchronic.Chronic;
import com.todoroo.astrid.data.Task;
@SuppressWarnings("nls")
public class TitleParser {
Task task;
ArrayList<String> tags;
@ -61,7 +61,6 @@ public class TitleParser {
}
//helper method for priorityHelper. converts the string to a Task Importance
@SuppressWarnings("nls")
private static int str_to_priority(String priority_str) {
if (priority_str!=null)
priority_str.toLowerCase().trim();
@ -86,12 +85,13 @@ public class TitleParser {
"(?i)()(\\shigh(est)?|\\slow(est)?|\\stop|\\sleast) ?priority$"
};
for (String importanceString:importanceStrings){
Pattern importancePattern= Pattern.compile(importanceString);
Pattern importancePattern = Pattern.compile(importanceString);
while (true){
Matcher m = importancePattern.matcher(inputText);
if(m.find()) {
task.setValue(Task.IMPORTANCE, str_to_priority(m.group(2).trim()));
inputText = inputText.substring(0, m.start()+1) + inputText.substring(m.end());
int start = m.start() == 0 ? 0 : m.start() + 1;
inputText = inputText.substring(0, start) + inputText.substring(m.end());
} else
break;
@ -118,7 +118,6 @@ public class TitleParser {
//Handles setting the task's date.
//Day of week (e.g. Monday, Tuesday,..) is overridden by a set date (e.g. October 23 2013).
//Vague times (e.g. breakfast, night) are overridden by a set time (9 am, at 10, 17:00)
@SuppressWarnings("nls")
private static void dayHelper(Task task ) {
String inputText = task.getValue(Task.TITLE);
Calendar cal = null;
@ -316,7 +315,6 @@ public class TitleParser {
//---------------------DATE--------------------------
//Parses through the text and sets the frequency of the task.
@SuppressWarnings("nls")
private static void repeatHelper(Task task) {
String inputText = task.getValue(Task.TITLE);
HashMap<String, Frequency> repeatTimes = new HashMap<String, Frequency>();

@ -19,7 +19,7 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksService;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.api.MoveListRequest;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
import com.todoroo.astrid.test.DatabaseTestCase;
@ -29,7 +29,7 @@ public class GtasksApiTest extends DatabaseTestCase {
private static final String DEFAULT_LIST = "@default";
private static final String TEST_ACCOUNT = "sync_tester2@astrid.com";
private static GtasksService service;
private static GtasksInvoker service;
private static boolean initialized = false;
private boolean bypassTests = false;
@ -178,7 +178,7 @@ public class GtasksApiTest extends DatabaseTestCase {
}
private boolean listHasTaskWithTitle(String listId, String title) throws Exception {
com.google.api.services.tasks.model.Tasks newListTasks = service.getAllGtasksFromListId(listId, false, false);
com.google.api.services.tasks.model.Tasks newListTasks = service.getAllGtasksFromListId(listId, false, false, 0);
List<Task> items = newListTasks.getItems();
if (items != null) {
for (Task t : items) {
@ -191,7 +191,7 @@ public class GtasksApiTest extends DatabaseTestCase {
}
private boolean taskWithTitleExists(String title) throws Exception {
Tasks defaultList = service.getAllGtasksFromListId(DEFAULT_LIST, false, false);
Tasks defaultList = service.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0);
List<Task> items = defaultList.getItems();
if (items != null) {
for (Task t : items) {
@ -270,7 +270,7 @@ public class GtasksApiTest extends DatabaseTestCase {
}
Preferences.setString(GtasksPreferenceService.PREF_USER_NAME, toUse.name);
AccountManagerFuture<Bundle> accountManagerFuture = manager.manager.getAuthToken(toUse, GtasksService.AUTH_TOKEN_TYPE, true, null, null);
AccountManagerFuture<Bundle> accountManagerFuture = manager.manager.getAuthToken(toUse, GtasksInvoker.AUTH_TOKEN_TYPE, true, null, null);
Bundle authTokenBundle = accountManagerFuture.getResult();
if (authTokenBundle.containsKey(AccountManager.KEY_INTENT)) {
@ -282,7 +282,7 @@ public class GtasksApiTest extends DatabaseTestCase {
String authToken = authTokenBundle.getString(AccountManager.KEY_AUTHTOKEN);
authToken = GtasksTokenValidator.validateAuthToken(getContext(), authToken);
service = new GtasksService(authToken);
service = new GtasksInvoker(authToken);
initialized = true;
}
@ -306,7 +306,7 @@ public class GtasksApiTest extends DatabaseTestCase {
private void clearDefaultList() {
try {
Tasks tasks = service.getAllGtasksFromListId(DEFAULT_LIST, false, false);
Tasks tasks = service.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0);
List<Task> items = tasks.getItems();
if (items != null) {
for (Task t : items) {

@ -22,7 +22,7 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksService;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
import com.todoroo.astrid.service.MetadataService;
@ -32,7 +32,7 @@ import com.todoroo.astrid.test.DatabaseTestCase;
@SuppressWarnings("nls")
public class GtasksNewSyncTest extends DatabaseTestCase {
private static GtasksService gtasksService;
private static GtasksInvoker gtasksService;
private GtasksSyncProvider syncProvider;
private static boolean initialized = false;
private boolean bypassTests = false;
@ -522,13 +522,13 @@ public class GtasksNewSyncTest extends DatabaseTestCase {
authToken = GtasksTokenValidator.validateAuthToken(getContext(), authToken);
gtasksPreferenceService.setToken(authToken);
gtasksService = new GtasksService(authToken);
gtasksService = new GtasksInvoker(authToken);
initialized = true;
}
private void setupTestList() throws Exception {
Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false);
Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0);
List<com.google.api.services.tasks.model.Task> items = defaultListTasks.getItems();
if (items != null) {
for (com.google.api.services.tasks.model.Task t : items) {

@ -12,7 +12,6 @@ import android.os.Bundle;
import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
import com.google.api.services.tasks.model.Tasks;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.utility.AndroidUtilities;
@ -21,20 +20,20 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksService;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
import com.todoroo.astrid.gtasks.sync.GtasksSyncOnSaveService;
import com.todoroo.astrid.gtasks.sync.GtasksSyncService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.test.DatabaseTestCase;
public class GtasksSyncOnSaveTest extends DatabaseTestCase {
@Autowired TaskService taskService;
@Autowired GtasksSyncOnSaveService gtasksSyncOnSaveService;
@Autowired GtasksSyncService gtasksSyncService;
@Autowired GtasksMetadataService gtasksMetadataService;
@Autowired GtasksPreferenceService gtasksPreferenceService;
private GtasksService gtasksService;
private GtasksInvoker gtasksService;
private boolean initialized = false;
private boolean bypassTests = false;
private static final String TEST_ACCOUNT = "sync_tester2@astrid.com";
@ -148,7 +147,7 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase {
}
private boolean taskWithTitleExists(String title) throws IOException {
Tasks allTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false);
Tasks allTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0);
List<com.google.api.services.tasks.model.Task> items = allTasks.getItems();
if (items != null) {
for (com.google.api.services.tasks.model.Task t : items) {
@ -165,9 +164,8 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase {
if (!initialized) {
initializeTestService();
gtasksSyncOnSaveService.initialize();
gtasksSyncService.initialize();
initialized = true;
Preferences.setBoolean(R.string.gtasks_GPr_sync_on_save_key, true);
}
setupTestList();
@ -205,13 +203,13 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase {
authToken = GtasksTokenValidator.validateAuthToken(getContext(), authToken);
gtasksPreferenceService.setToken(authToken);
gtasksService = new GtasksService(authToken);
gtasksService = new GtasksInvoker(authToken);
initialized = true;
}
private void setupTestList() throws Exception {
Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false);
Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0);
List<com.google.api.services.tasks.model.Task> items = defaultListTasks.getItems();
if (items != null) {
for (com.google.api.services.tasks.model.Task t : items) {

@ -23,7 +23,7 @@ import com.todoroo.astrid.gtasks.GtasksMetadata;
import com.todoroo.astrid.gtasks.GtasksMetadataService;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksService;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
import com.todoroo.astrid.repeats.NewRepeatTests;
@ -40,7 +40,7 @@ public class RepeatTestsGtasksSync extends NewRepeatTests<com.google.api.service
public static final String DEFAULT_LIST = "@default";
private static boolean initialized = false;
protected static GtasksService gtasksService;
protected static GtasksInvoker gtasksService;
@Override
protected void setUp() throws Exception {
@ -139,13 +139,13 @@ public class RepeatTestsGtasksSync extends NewRepeatTests<com.google.api.service
authToken = GtasksTokenValidator.validateAuthToken(getContext(), authToken);
gtasksPreferenceService.setToken(authToken);
gtasksService = new GtasksService(authToken);
gtasksService = new GtasksInvoker(authToken);
initialized = true;
}
private void setupTestList() throws Exception {
Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false);
Tasks defaultListTasks = gtasksService.getAllGtasksFromListId(DEFAULT_LIST, false, false, 0);
List<com.google.api.services.tasks.model.Task> items = defaultListTasks.getItems();
if (items != null) {
for (com.google.api.services.tasks.model.Task t : items) {

Loading…
Cancel
Save