(4);
- /**
- * URI parameter to signal that the caller is a sync adapter.
- */
+ /** URI parameter to signal that the caller is a sync adapter. */
public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
- /**
- * URI parameter to signal the request of the extended properties of a task.
- */
+ /** URI parameter to signal the request of the extended properties of a task. */
public static final String LOAD_PROPERTIES = "load_properties";
- /**
- * URI parameter to submit the account name of the account we operate on.
- */
+ /** URI parameter to submit the account name of the account we operate on. */
public static final String ACCOUNT_NAME = "account_name";
- /**
- * URI parameter to submit the account type of the account we operate on.
- */
+ /** URI parameter to submit the account type of the account we operate on. */
public static final String ACCOUNT_TYPE = "account_type";
- /**
- * Account name for local, unsynced task lists.
- */
+ /** Account name for local, unsynced task lists. */
public static final String LOCAL_ACCOUNT_NAME = "Local";
- /**
- * Account type for local, unsynced task lists.
- */
+ /** Account type for local, unsynced task lists. */
public static final String LOCAL_ACCOUNT_TYPE = "org.dmfs.account.LOCAL";
/**
- * Broadcast action that's sent when the task database has been initialized, either because the app was launched for the first time or because the app was
+ * Broadcast action that's sent when the task database has been initialized,
+ * either because the app was launched for the first time or because the app was
* launched after the user cleared the app data.
- *
- * The intent data represents the authority of the provider, the MIME type will be {@link #MIMETYPE_AUTHORITY}.
+ *
+ *
+ * The intent data represents the authority of the provider, the MIME type will
+ * be {@link #MIMETYPE_AUTHORITY}.
*/
public static final String ACTION_DATABASE_INITIALIZED = "org.dmfs.tasks.DATABASE_INITIALIZED";
/**
- * A MIME type of an authority. Authorities itself don't seem to have a MIME type in Android, so we just use our own.
+ * A MIME type of an authority. Authorities itself don't seem to have a MIME
+ * type in Android, so we just use our own.
*/
- public static final String MIMETYPE_AUTHORITY = ContentResolver.CURSOR_DIR_BASE_TYPE + "/vnd.org.dmfs.authority.mimetype";
+ public static final String MIMETYPE_AUTHORITY = ContentResolver.CURSOR_DIR_BASE_TYPE
+ + "/vnd.org.dmfs.authority.mimetype";
/**
- * The action of the broadcast that's send when a task becomes due. The intent data will be a {@link Uri} of the task that became due.
+ * The action of the broadcast that's send when a task becomes due. The intent
+ * data will be a {@link Uri} of the task that became due.
*/
public static final String ACTION_BROADCAST_TASK_DUE = "org.dmfs.android.tasks.TASK_DUE";
/**
- * The action of the broadcast that's send when a task starts. The intent data will be a {@link Uri} of the task that has started.
+ * The action of the broadcast that's send when a task starts. The intent data
+ * will be a {@link Uri} of the task that has started.
*/
public static final String ACTION_BROADCAST_TASK_STARTING = "org.dmfs.android.tasks.TASK_START";
/**
- * A Long extra that contains a timestamp of the event that's triggered. So this is either the timestamp of the start or due date of the task.
+ * A Long extra that contains a timestamp of the event that's triggered. So this
+ * is either the timestamp of the start or due date of the task.
*/
- public final static String EXTRA_TASK_TIMESTAMP = "org.dmfs.provider.tasks.extra.TIMESTAMP";
+ public static final String EXTRA_TASK_TIMESTAMP = "org.dmfs.provider.tasks.extra.TIMESTAMP";
/**
- * A Boolean extra to indicate that the event that was triggered is an all-day date.
+ * A Boolean extra to indicate that the event that was triggered is an all-day
+ * date.
*/
- public final static String EXTRA_TASK_ALLDAY = "org.dmfs.provider.tasks.extra.ALLDAY";
+ public static final String EXTRA_TASK_ALLDAY = "org.dmfs.provider.tasks.extra.ALLDAY";
- /**
- * A String extra containing the timezone id of the task.
- */
- public final static String EXTRA_TASK_TIMEZONE = "org.dmfs.provider.tasks.extra.TIMEZONE";
+ /** A String extra containing the timezone id of the task. */
+ public static final String EXTRA_TASK_TIMEZONE = "org.dmfs.provider.tasks.extra.TIMEZONE";
- /**
- * A String extra containing the title of the task.
- */
- public final static String EXTRA_TASK_TITLE = "org.dmfs.provider.tasks.extra.TITLE";
+ /** A String extra containing the title of the task. */
+ public static final String EXTRA_TASK_TITLE = "org.dmfs.provider.tasks.extra.TITLE";
/**
- * The name of the {@link Intent#ACTION_PROVIDER_CHANGED} extra that contains the {@link ArrayList} of {@link Uri}s that have been modified. This always
- * goes along with an {@link #EXTRA_OPERATIONS} which contains a code for the operation executed on a Uri at the same index.
+ * The name of the {@link Intent#ACTION_PROVIDER_CHANGED} extra that contains
+ * the {@link ArrayList} of {@link Uri}s that have been modified. This always
+ * goes along with an {@link #EXTRA_OPERATIONS} which contains a code for the
+ * operation executed on a Uri at the same index.
*/
- public final static String EXTRA_OPERATIONS_URIS = "org.dmfs.tasks.OPERATIONS_URIS";
+ public static final String EXTRA_OPERATIONS_URIS = "org.dmfs.tasks.OPERATIONS_URIS";
/**
- * The name of the {@link Intent#ACTION_PROVIDER_CHANGED} extra that contains the {@link ArrayList} of provider operation codes. The following codes are
+ * The name of the {@link Intent#ACTION_PROVIDER_CHANGED} extra that contains
+ * the {@link ArrayList} of provider operation codes. The following codes are
* used:
+ *
*
- * - 0 - for inserts
- * - 1 - for updates
- * - 2 - for deletes
+ * - 0 - for inserts
+ *
- 1 - for updates
+ *
- 2 - for deletes
*
*/
- public final static String EXTRA_OPERATIONS = "org.dmfs.tasks.OPERATIONS";
+ public static final String EXTRA_OPERATIONS = "org.dmfs.tasks.OPERATIONS";
-
- /**
- * Private constructor to prevent instantiation.
- */
- private TaskContract()
- {
+ /** Private constructor to prevent instantiation. */
+ private TaskContract() {
}
-
/**
- * A table provided for sync adapters to use for storing private sync state data.
- *
- * Only sync adapters are allowed to access this table and they may access their own rows only.
- *
- * Note that only one row per account will be stored. Updating or inserting a sync state for a specific account will override any previous sync state for
+ * A table provided for sync adapters to use for storing private sync state
+ * data.
+ *
+ *
+ * Only sync adapters are allowed to access this table and they may access their
+ * own rows only.
+ *
+ *
+ * Note that only one row per account will be stored. Updating or inserting a
+ * sync state for a specific account will override any previous sync state for
* this account.
*/
- public static class SyncState implements SyncStateContract.Columns, BaseColumns
- {
- public final static String CONTENT_URI_PATH = "syncstate";
-
+ public static class SyncState implements SyncStateContract.Columns, BaseColumns {
+ public static final String CONTENT_URI_PATH = "syncstate";
/**
* Get the sync state content {@link Uri} using the given authority.
*
* @param authority
- * The authority.
- *
+ * The authority.
* @return A {@link Uri}.
*/
- public static Uri getContentUri(String authority)
- {
+ public static Uri getContentUri(String authority) {
return getUriFactory(authority).getUri(CONTENT_URI_PATH);
}
-
}
-
/**
* Get the base content {@link Uri} using the given authority.
*
* @param authority
- * The authority.
- *
+ * The authority.
* @return A {@link Uri}.
*/
- public static Uri getContentUri(String authority)
- {
+ public static Uri getContentUri(String authority) {
return getUriFactory(authority).getUri();
}
-
/**
- * A set of columns for synchronization purposes. These columns exist in {@link Tasks} and in {@link TaskLists} but have different meanings. Only sync
+ * A set of columns for synchronization purposes. These columns exist in
+ * {@link Tasks} and in {@link TaskLists} but have different meanings. Only sync
* adapters are allowed to change these values.
*
* @author Marten Gajda
*/
- public interface CommonSyncColumns
- {
+ public interface CommonSyncColumns {
/**
* A unique Sync ID as set by the sync adapter.
+ *
*
* Value: String
- *
*/
String _SYNC_ID = "_sync_id";
/**
* Sync version as set by the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC_VERSION = "sync_version";
/**
* Indicates that a task or a task list has been changed.
+ *
*
* Value: Integer
- *
*/
String _DIRTY = "_dirty";
/**
* A general purpose column for the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC1 = "sync1";
/**
* A general purpose column for the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC2 = "sync2";
/**
* A general purpose column for the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC3 = "sync3";
/**
* A general purpose column for the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC4 = "sync4";
/**
* A general purpose column for the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC5 = "sync5";
/**
* A general purpose column for the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC6 = "sync6";
/**
* A general purpose column for the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC7 = "sync7";
/**
* A general purpose column for the sync adapter.
+ *
*
* Value: String
- *
*/
String SYNC8 = "sync8";
-
}
-
/**
* Additional sync columns for task lists.
*
* @author Marten Gajda
*/
- public interface TaskListSyncColumns
- {
+ public interface TaskListSyncColumns {
/**
* The name of the account this list belongs to. This field is write-once.
+ *
*
* Value: String
- *
*/
String ACCOUNT_NAME = "account_name";
/**
* The type of the account this list belongs to. This field is write-once.
+ *
*
* Value: String
- *
*/
String ACCOUNT_TYPE = "account_type";
}
-
/**
* Additional sync columns for tasks.
*
* @author Marten Gajda
*/
- public interface TaskSyncColumns
- {
+ public interface TaskSyncColumns {
/**
* The UID of a task. This is field can be changed by a sync adapter only.
+ *
*
* Value: String
- *
*/
String _UID = "_uid";
/**
- * Deleted flag of a task. This is set to 1 by the content provider when a task app deletes a task. The sync adapter has to remove the task
- * again to finish the removal. This value is read-only.
+ * Deleted flag of a task. This is set to 1 by the content provider
+ * when a task app deletes a task. The sync adapter has to remove the task again
+ * to finish the removal. This value is read-only.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
String _DELETED = "_deleted";
}
-
/**
* Data columns of task lists.
*
* @author Marten Gajda
*/
- public interface TaskListColumns
- {
+ public interface TaskListColumns {
/**
* List ID.
+ *
*
* Value: Long
- *
+ *
*
* read-only
- *
*/
String _ID = "_id";
/**
* The name of the task list.
+ *
*
* Value: String
- *
*/
String LIST_NAME = "list_name";
/**
- * The color of this list as integer (0xaarrggbb). Only the sync adapter can change this.
+ * The color of this list as integer (0xaarrggbb). Only the sync adapter can
+ * change this.
+ *
*
* Value: Integer
- *
*/
String LIST_COLOR = "list_color";
/**
- * The access level a user has on this list. This value is not used yet, sync adapters should set it to 0.
+ * The access level a user has on this list. This value is not used yet,
+ * sync adapters should set it to 0.
+ *
*
* Value: Integer
- *
*/
String ACCESS_LEVEL = "list_access_level";
/**
* Indicates that a task list is set to be visible.
+ *
*
* Value: Integer (0 or 1)
- *
*/
String VISIBLE = "visible";
/**
* Indicates that a task list is set to be synced.
+ *
*
* Value: Integer (0 or 1)
- *
*/
String SYNC_ENABLED = "sync_enabled";
/**
* The email address of the list owner.
+ *
*
* Value: String
- *
*/
String OWNER = "list_owner";
-
}
-
/**
* The task list table holds one entry for each task list.
*
* @author Marten Gajda
*/
- public static final class TaskLists implements TaskListColumns, TaskListSyncColumns, CommonSyncColumns
- {
+ public static final class TaskLists implements TaskListColumns, TaskListSyncColumns, CommonSyncColumns {
public static final String CONTENT_URI_PATH = "tasklists";
- /**
- * The default sort order.
- */
+ /** The default sort order. */
public static final String DEFAULT_SORT_ORDER = ACCOUNT_NAME + ", " + LIST_NAME;
- /**
- * An array of columns only a sync adapter is allowed to change.
- */
- public static final String[] SYNC_ADAPTER_COLUMNS = new String[] {
- ACCESS_LEVEL, _DIRTY, OWNER, SYNC1, SYNC2, SYNC3, SYNC4, SYNC5, SYNC6, SYNC7, SYNC8,
- _SYNC_ID, SYNC_VERSION, };
-
+ /** An array of columns only a sync adapter is allowed to change. */
+ public static final String[] SYNC_ADAPTER_COLUMNS = new String[]{ACCESS_LEVEL, _DIRTY, OWNER, SYNC1, SYNC2,
+ SYNC3, SYNC4, SYNC5, SYNC6, SYNC7, SYNC8, _SYNC_ID, SYNC_VERSION,};
/**
* Get the task list content {@link Uri} using the given authority.
*
* @param authority
- * The authority.
- *
+ * The authority.
* @return A {@link Uri}.
*/
- public static Uri getContentUri(String authority)
- {
+ public static Uri getContentUri(String authority) {
return getUriFactory(authority).getUri(CONTENT_URI_PATH);
}
-
}
-
/**
* Task data columns. Defines all the values a task can have at most once.
*
* @author Marten Gajda
*/
- public interface TaskColumns extends BaseColumns
- {
+ public interface TaskColumns extends BaseColumns {
/**
* The row id of a task. This value is read-only
+ *
*
* Value: Integer
- *
*/
String _ID = "_id";
/**
- * The local version number of this task. The only guarantee about the value is, it's incremented whenever the task changes (this includes any
- * changes applied by sync adapters).
+ * The local version number of this task. The only guarantee about the value is,
+ * it's incremented whenever the task changes (this includes any changes applied
+ * by sync adapters).
+ *
*
- * Note, there is no guarantee about how much it's incremented other than by at least 1.
+ * Note, there is no guarantee about how much it's incremented other than by at
+ * least 1.
+ *
*
* Value: Integer
+ *
*
* read-only
*/
String VERSION = "version";
/**
- * The id of the list this task belongs to. This value is write-once and must not be null.
+ * The id of the list this task belongs to. This value is
+ * write-once and must not be null.
+ *
*
* Value: Integer
- *
*/
String LIST_ID = "list_id";
/**
* The title of the task.
+ *
*
* Value: String
- *
*/
String TITLE = "title";
/**
* The location of the task.
+ *
*
* Value: String
- *
*/
String LOCATION = "location";
/**
- * A geographic location related to the task. The should be a string in the format "longitude,latitude".
+ * A geographic location related to the task. The should be a string in the
+ * format "longitude,latitude".
+ *
*
* Value: String
- *
*/
String GEO = "geo";
/**
* The description of a task.
+ *
*
* Value: String
- *
*/
String DESCRIPTION = "description";
/**
- * The URL iCalendar field for this task. Must be a valid URI if not null-
+ * The URL iCalendar field for this task. Must be a valid URI if not
+ * null-
+ *
*
* Value: String
- *
*/
String URL = "url";
/**
* The email address of the organizer if any, {@code null} otherwise.
+ *
*
* Value: String
- *
*/
String ORGANIZER = "organizer";
/**
- * The priority of a task. This is an Integer between zero and 9. Zero means there is no priority set. 1 is the highest priority and 9 the lowest.
+ * The priority of a task. This is an Integer between zero and 9. Zero means
+ * there is no priority set. 1 is the highest priority and 9 the lowest.
+ *
*
* Value: Integer
- *
*/
String PRIORITY = "priority";
- /**
- * The default value of {@link #PRIORITY}.
- */
+ /** The default value of {@link #PRIORITY}. */
int PRIORITY_DEFAULT = 0;
/**
- * The classification of a task. This value must be either null or one of {@link #CLASSIFICATION_PUBLIC}, {@link #CLASSIFICATION_PRIVATE},
+ * The classification of a task. This value must be either null or
+ * one of {@link #CLASSIFICATION_PUBLIC}, {@link #CLASSIFICATION_PRIVATE},
* {@link #CLASSIFICATION_CONFIDENTIAL}.
+ *
*
* Value: Integer
- *
*/
String CLASSIFICATION = "class";
- /**
- * Classification value for public tasks.
- */
+ /** Classification value for public tasks. */
int CLASSIFICATION_PUBLIC = 0;
- /**
- * Classification value for private tasks.
- */
+ /** Classification value for private tasks. */
int CLASSIFICATION_PRIVATE = 1;
- /**
- * Classification value for confidential tasks.
- */
+ /** Classification value for confidential tasks. */
int CLASSIFICATION_CONFIDENTIAL = 2;
- /**
- * Default value of {@link #CLASSIFICATION}.
- */
+ /** Default value of {@link #CLASSIFICATION}. */
Integer CLASSIFICATION_DEFAULT = null;
/**
- * Date of completion of this task in milliseconds since the epoch or {@code null} if this task has not been completed yet.
+ * Date of completion of this task in milliseconds since the epoch or
+ * {@code null} if this task has not been completed yet.
+ *
*
* Value: Long
- *
*/
String COMPLETED = "completed";
/**
* Indicates that the date of completion is an all-day date.
+ *
*
* Value: Integer
- *
*/
String COMPLETED_IS_ALLDAY = "completed_is_allday";
/**
- * A number between 0 and 100 that indicates the progress of the task or null.
+ * A number between 0 and 100 that indicates the progress of the task or
+ * null.
+ *
*
* Value: Integer (0-100)
- *
*/
String PERCENT_COMPLETE = "percent_complete";
/**
- * The status of this task. One of {@link #STATUS_NEEDS_ACTION},{@link #STATUS_IN_PROCESS}, {@link #STATUS_COMPLETED}, {@link #STATUS_CANCELLED}.
+ * The status of this task. One of
+ * {@link #STATUS_NEEDS_ACTION},{@link #STATUS_IN_PROCESS},
+ * {@link #STATUS_COMPLETED}, {@link #STATUS_CANCELLED}.
+ *
*
* Value: Integer
- *
*/
String STATUS = "status";
- /**
- * A specific status indicating that nothing has been done yet.
- */
+ /** A specific status indicating that nothing has been done yet. */
int STATUS_NEEDS_ACTION = 0;
- /**
- * A specific status indicating that some work has been done.
- */
+ /** A specific status indicating that some work has been done. */
int STATUS_IN_PROCESS = 1;
- /**
- * A specific status indicating that the task is completed.
- */
+ /** A specific status indicating that the task is completed. */
int STATUS_COMPLETED = 2;
- /**
- * A specific status indicating that the task has been cancelled.
- */
+ /** A specific status indicating that the task has been cancelled. */
int STATUS_CANCELLED = 3;
- /**
- * The default status is "needs action".
- */
+ /** The default status is "needs action". */
int STATUS_DEFAULT = STATUS_NEEDS_ACTION;
/**
- * A flag that indicates a task is new (i.e. not work has been done yet). This flag is read-only. Its value is 1 when
- * {@link #STATUS} equals {@link #STATUS_NEEDS_ACTION} and 0 otherwise.
+ * A flag that indicates a task is new (i.e. not work has been done yet). This
+ * flag is read-only. Its value is 1 when
+ * {@link #STATUS} equals {@link #STATUS_NEEDS_ACTION} and 0
+ * otherwise.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
String IS_NEW = "is_new";
/**
- * A flag that indicates a task is closed (no more work has to be done). This flag is read-only. Its value is 1 when
- * {@link #STATUS} equals {@link #STATUS_COMPLETED} or {@link #STATUS_CANCELLED} and 0 otherwise.
+ * A flag that indicates a task is closed (no more work has to be done). This
+ * flag is read-only. Its value is 1 when
+ * {@link #STATUS} equals {@link #STATUS_COMPLETED} or {@link #STATUS_CANCELLED}
+ * and 0 otherwise.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
String IS_CLOSED = "is_closed";
/**
- * An individual color for this task in the format 0xaarrggbb or {@code null} to use {@link TaskListColumns#LIST_COLOR} instead.
+ * An individual color for this task in the format 0xaarrggbb or {@code null} to
+ * use {@link TaskListColumns#LIST_COLOR} instead.
+ *
*
* Value: Integer
- *
*/
String TASK_COLOR = "task_color";
/**
* When this task starts in milliseconds since the epoch.
+ *
*
* Value: Long
- *
*/
String DTSTART = "dtstart";
- /**
- * Boolean: flag that indicates that this is an all-day task.
- */
+ /** Boolean: flag that indicates that this is an all-day task. */
String IS_ALLDAY = "is_allday";
/**
* When this task has been created in milliseconds since the epoch.
+ *
*
* Value: Long
- *
*/
String CREATED = "created";
/**
- * When this task had been modified the last time in milliseconds since the epoch.
+ * When this task had been modified the last time in milliseconds since the
+ * epoch.
+ *
*
* Value: Long
- *
*/
String LAST_MODIFIED = "last_modified";
/**
- * String: An Olson Id of the time zone of this task. If this value is null, it's automatically replaced by the local time zone.
+ * String: An Olson Id of the time zone of this task. If this value is
+ * null, it's automatically replaced by the local time zone.
*/
String TZ = "tz";
/**
- * When this task is due in milliseconds since the epoch. Only one of {@link #DUE} or {@link #DURATION} must be supplied (or none of both if the task
- * has no due date).
+ * When this task is due in milliseconds since the epoch. Only one of
+ * {@link #DUE} or {@link #DURATION} must be supplied (or none of both if the
+ * task has no due date).
+ *
*
* Value: Long
- *
*/
String DUE = "due";
/**
- * The duration of this task. Only one of {@link #DUE} or {@link #DURATION} must be supplied (or none of both if the task has no due date). Setting a
- * {@link #DURATION} is not allowed when {@link #DTSTART} is null. The Value must be a duration string as in RFC 5545 Section 3.3.6.
+ * The duration of this task. Only one of {@link #DUE} or {@link #DURATION} must
+ * be supplied (or none of both if the task has no due date). Setting a
+ * {@link #DURATION} is not allowed when {@link #DTSTART} is null.
+ * The Value must be a duration string as in
+ * RFC 5545 Section
+ * 3.3.6.
+ *
*
* Value: String
- *
*/
String DURATION = "duration";
/**
- * A comma separated list of time Strings in RFC 5545 format (see RFC 5545 Section 3.3.4
- * and RFC 5545 Section 3.3.5) that contains dates of instances of e recurring task.
- * All-day tasks must use the DATE format specified in section 3.3.4 of RFC 5545.
+ * A comma separated list of time Strings in RFC 5545 format (see
+ * RFC 5545 Section
+ * 3.3.4 and RFC
+ * 5545 Section 3.3.5) that contains dates of instances of e recurring task.
+ * All-day tasks must use the DATE format specified in section 3.3.4 of RFC
+ * 5545.
+ *
*
* This value must be {@code null} for exception instances.
+ *
*
* Value: String
- *
*/
String RDATE = "rdate";
/**
- * A comma separated list of time Strings in RFC 5545 format (see RFC 5545 Section 3.3.4
- * and RFC 5545 Section 3.3.5) that contains dates of exceptions of a recurring task.
- * All-day tasks must use the DATE format specified in section 3.3.4 of RFC 5545.
+ * A comma separated list of time Strings in RFC 5545 format (see
+ * RFC 5545 Section
+ * 3.3.4 and RFC
+ * 5545 Section 3.3.5) that contains dates of exceptions of a recurring
+ * task. All-day tasks must use the DATE format specified in section 3.3.4 of
+ * RFC 5545.
+ *
*
* This value must be {@code null} for exception instances.
+ *
*
* Value: String
- *
*/
String EXDATE = "exdate";
/**
- * A recurrence rule as specified in RFC 5545 Section 3.3.10.
+ * A recurrence rule as specified in
+ * RFC 5545 Section
+ * 3.3.10.
+ *
*
* This value must be {@code null} for exception instances.
+ *
*
* Value: String
- *
*/
String RRULE = "rrule";
/**
- * The _sync_id of the original event if this is an exception, null otherwise. Only one of {@link #ORIGINAL_INSTANCE_SYNC_ID} or
- * {@link #ORIGINAL_INSTANCE_ID} must be set if this task is an exception. The other one will be updated by the content provider.
+ * The _sync_id of the original event if this is an exception, null
+ * otherwise. Only one of {@link #ORIGINAL_INSTANCE_SYNC_ID} or
+ * {@link #ORIGINAL_INSTANCE_ID} must be set if this task is an exception. The
+ * other one will be updated by the content provider.
+ *
*
* Value: String
- *
*/
String ORIGINAL_INSTANCE_SYNC_ID = "original_instance_sync_id";
/**
- * The row id of the original event if this is an exception, null otherwise. Only one of {@link #ORIGINAL_INSTANCE_SYNC_ID} or
- * {@link #ORIGINAL_INSTANCE_ID} must be set if this task is an exception. The other one will be updated by the content provider.
+ * The row id of the original event if this is an exception, null
+ * otherwise. Only one of {@link #ORIGINAL_INSTANCE_SYNC_ID} or
+ * {@link #ORIGINAL_INSTANCE_ID} must be set if this task is an exception. The
+ * other one will be updated by the content provider.
+ *
*
* Value: Long
- *
*/
String ORIGINAL_INSTANCE_ID = "original_instance_id";
/**
- * The time in milliseconds since the Epoch of the original instance that is overridden by this instance or null if this task is not a
+ * The time in milliseconds since the Epoch of the original instance that is
+ * overridden by this instance or null if this task is not a
* recurring instance.
+ *
*
* Value: Long
- *
*/
String ORIGINAL_INSTANCE_TIME = "original_instance_time";
/**
* A flag indicating that the original instance was an all-day task.
+ *
*
* Value: Integer
- *
*/
String ORIGINAL_INSTANCE_ALLDAY = "original_instance_allday";
/**
- * The row id of the parent task. null if the task has no parent task.
+ * The row id of the parent task. null if the task has no parent
+ * task.
+ *
*
- * Note, when writing this value the task {@link Property.Relation} properties are updated accordingly. Any parent or child relations which
- * make this a child of another task are deleted and a new {@link Property.Relation#RELTYPE_PARENT} relation pointing to the new parent is created.
- * Be aware that Siblings will be split, i.e. they are not moved to the new parent. Currently this might cause siblings to become orphans if they
- * don't have a parent-child relationship. This behavior may change in future version.
- *
+ * Note, when writing this value the task {@link Property.Relation} properties
+ * are updated accordingly. Any parent or child relations which make this a
+ * child of another task are deleted and a new
+ * {@link Property.Relation#RELTYPE_PARENT} relation pointing to the new parent
+ * is created. Be aware that Siblings will be split, i.e. they are not moved to
+ * the new parent. Currently this might cause siblings to become orphans if they
+ * don't have a parent-child relationship. This behavior may change in future
+ * version.
*
*
* Value: Long
- *
*/
String PARENT_ID = "parent_id";
/**
* The sorting of this task under it's parent task.
+ *
*
* Value: String
- *
*/
String SORTING = "sorting";
/**
- * Indicates how many alarms a task has. 0 means the task has no alarms. This field is read only as it's set automatically.
+ * Indicates how many alarms a task has. 0 means the task has no
+ * alarms. This field is read only as it's set automatically.
+ *
*
- * Value: Integer
- *
- * Read-only
+ * Value: Integer Read-only
*/
String HAS_ALARMS = "has_alarms";
/**
- * Indicates that this task has extended properties like attachments, alarms or relations. This field is read only as it's set automatically.
+ * Indicates that this task has extended properties like attachments, alarms or
+ * relations. This field is read only as it's set automatically.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
String HAS_PROPERTIES = "has_properties";
/**
- * Indicates that this task has been pinned to the notification area. This flag is moved to the exception when an exception for the first instance of a
- * recurring task is created. That means, if you edit a pinned recurring task, the pinned flag is moved to the exception and cleared from the master
- * task.
+ * Indicates that this task has been pinned to the notification area. This flag
+ * is moved to the exception when an exception for the first instance of a
+ * recurring task is created. That means, if you edit a pinned recurring task,
+ * the pinned flag is moved to the exception and cleared from the master task.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
String PINNED = "pinned";
}
-
/**
* Columns that are valid in a search query.
*
* @author Marten Gajda
*/
- public interface TaskSearchColumns
- {
+ public interface TaskSearchColumns {
/**
- * The score of a task in a search result. It's an indicator for the relevance of the task. Value is in (0, 1.0] where 0 would be "no relevance" at all
+ * The score of a task in a search result. It's an indicator for the relevance
+ * of the task. Value is in (0, 1.0] where 0 would be "no relevance" at all
* (though the result doesn't contain such tasks).
+ *
*
* Value: Float
- *
*/
String SCORE = "score";
}
-
/**
* The task table stores the data of all tasks.
*
* @author Marten Gajda
*/
- public static final class Tasks implements TaskColumns, CommonSyncColumns, TaskSyncColumns, TaskSearchColumns
- {
+ public static final class Tasks implements TaskColumns, CommonSyncColumns, TaskSyncColumns, TaskSearchColumns {
/**
- * The name of the account the task belongs to. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The name of the account the task belongs to. This is auto-derived from the
+ * list the task belongs to. Do not write this value here.
+ *
*
* Value: String
- *
+ *
*
* read-only
- *
*/
public static final String ACCOUNT_NAME = TaskLists.ACCOUNT_NAME;
/**
- * The type of the account the task belongs to. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The type of the account the task belongs to. This is auto-derived from the
+ * list the task belongs to. Do not write this value here.
+ *
*
* Value: String
- *
+ *
*
* read-only
- *
*/
public static final String ACCOUNT_TYPE = TaskLists.ACCOUNT_TYPE;
/**
- * The name of the list this task belongs to as integer (0xaarrggbb). This is auto-derived from the list the task belongs to. Do not write this value
- * here.
+ * The name of the list this task belongs to as integer (0xaarrggbb). This is
+ * auto-derived from the list the task belongs to. Do not write this value here.
+ *
*
* Value: String
- *
+ *
*
* read-only
- *
*/
public static final String LIST_NAME = TaskLists.LIST_NAME;
+
/**
- * The color of the list this task belongs to as integer (0xaarrggbb). This is auto-derived from the list the task belongs to. Do not write this value
- * here. To change the color of an individual task use {@code TASK_COLOR} instead.
+ * The color of the list this task belongs to as integer (0xaarrggbb). This is
+ * auto-derived from the list the task belongs to. Do not write this value here.
+ * To change the color of an individual task use {@code TASK_COLOR} instead.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
public static final String LIST_COLOR = TaskLists.LIST_COLOR;
/**
- * The owner of the list this task belongs. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The owner of the list this task belongs. This is auto-derived from the list
+ * the task belongs to. Do not write this value here.
+ *
*
* Value: String
- *
+ *
*
* read-only
- *
*/
public static final String LIST_OWNER = TaskLists.OWNER;
/**
- * The access level of the list this task belongs. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The access level of the list this task belongs. This is auto-derived from the
+ * list the task belongs to. Do not write this value here.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
public static final String LIST_ACCESS_LEVEL = TaskLists.ACCESS_LEVEL;
/**
- * The visibility of the list this task belongs. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The visibility of the list this task belongs. This is auto-derived from the
+ * list the task belongs to. Do not write this value here.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
public static final String VISIBLE = "visible";
@@ -961,260 +957,370 @@ public final class TaskContract
public static final String DEFAULT_SORT_ORDER = DUE;
- public static final String[] SYNC_ADAPTER_COLUMNS = new String[] {
- _DIRTY, SYNC1, SYNC2, SYNC3, SYNC4, SYNC5, SYNC6, SYNC7, SYNC8, _SYNC_ID,
- SYNC_VERSION, };
-
+ public static final String[] SYNC_ADAPTER_COLUMNS = new String[]{_DIRTY, SYNC1, SYNC2, SYNC3, SYNC4, SYNC5,
+ SYNC6, SYNC7, SYNC8, _SYNC_ID, SYNC_VERSION,};
/**
* Get the tasks content {@link Uri} using the given authority.
*
* @param authority
- * The authority.
- *
+ * The authority.
* @return A {@link Uri}.
*/
- public static Uri getContentUri(String authority)
- {
+ public static Uri getContentUri(String authority) {
return getUriFactory(authority).getUri(CONTENT_URI_PATH);
}
-
- public static Uri getSearchUri(String authority, String query)
- {
+ public static Uri getSearchUri(String authority, String query) {
Uri.Builder builder = getUriFactory(authority).getUri(SEARCH_URI_PATH).buildUpon();
builder.appendQueryParameter(SEARCH_QUERY_PARAMETER, Uri.encode(query));
return builder.build();
}
}
-
/**
* Columns of a task instance.
*
* @author Yannic Ahrens
* @author Marten Gajda
*/
- public interface InstanceColumns
- {
+ public interface InstanceColumns {
/**
* _ID of task this instance belongs to.
+ *
*
* Value: Long
- *
*/
String TASK_ID = "task_id";
/**
- * The start date of an instance in milliseconds since the epoch or null if the instance has no start date. At present this is read only.
+ * The start date of an instance in milliseconds since the epoch or
+ * null if the instance has no start date. At present this is read
+ * only.
+ *
*
* Value: Long
- *
*/
String INSTANCE_START = "instance_start";
/**
- * The due date of an instance in milliseconds since the epoch or null if the instance has no due date. At present this is read only.
+ * The due date of an instance in milliseconds since the epoch or
+ * null if the instance has no due date. At present this is read
+ * only.
+ *
*
* Value: Long
- *
*/
String INSTANCE_DUE = "instance_due";
/**
- * This column should be used in an order clause to sort instances by start date. The only guarantee about the values in this column is the sort order.
+ * This column should be used in an order clause to sort instances by start
+ * date. The only guarantee about the values in this column is the sort order.
* Don't make any other assumptions about the value.
+ *
*
* Value: Long
- *
+ *
*
* read-only
- *
*/
String INSTANCE_START_SORTING = "instance_start_sorting";
/**
- * This column should be used in an order clause to sort instances by due date. The only guarantee about the values in this column is the sort order.
- * Don't make any other assumptions about the value.
+ * This column should be used in an order clause to sort instances by due date.
+ * The only guarantee about the values in this column is the sort order. Don't
+ * make any other assumptions about the value.
+ *
*
* Value: Long
- *
+ *
*
* read-only
- *
*/
String INSTANCE_DUE_SORTING = "instance_due_sorting";
/**
- * The duration of an instance in milliseconds or null if the instance has only one of start or due date or none of both. At present this
+ * The duration of an instance in milliseconds or null if the
+ * instance has only one of start or due date or none of both. At present this
* is read only.
+ *
*
* Value: Long
- *
*/
String INSTANCE_DURATION = "instance_duration";
/**
- * The start of the original instance as specified in the master task. For non-recurring task instances this is {@code null}.
+ * The start of the original instance as specified in the master task. For
+ * non-recurring task instances this is {@code null}.
+ *
*
- * For recurring tasks, these are the timestamps which have been derived from the recurrence rule or dates, except those specified as exdates.
+ * For recurring tasks, these are the timestamps which have been derived from
+ * the recurrence rule or dates, except those specified as exdates.
*/
String INSTANCE_ORIGINAL_TIME = "instance_original_time";
/**
- * The distance of the instance from the current one. For closed instances this is always {@code -1}, for the current instance this is {@code 0}. For
- * the instance after the current one this is {@code 1}, for the instance after that one it's {@code 2}, etc..
+ * The distance of the instance from the current one. For closed instances this
+ * is always {@code
+ * -1}, for the current instance this is {@code 0}. For the instance after the
+ * current one this is {@code 1}, for the instance after that one it's
+ * {@code 2}, etc..
+ *
*
* Value: Integer
+ *
*
* read-only
*/
String DISTANCE_FROM_CURRENT = "distance_from_current";
}
-
/**
- * A table containing one entry per task instance. This table is writable in order to allow modification of single instances of a task. Write operations to
- * this table will be converted into operations on overrides and forwarded to the task table.
+ * A table containing one entry per task instance. This table is writable in
+ * order to allow modification of single instances of a task. Write operations
+ * to this table will be converted into operations on overrides and forwarded to
+ * the task table.
+ *
*
- * Note: The {@link #DTSTART}, {@link #DUE} values of instances of recurring tasks represent the actual instance values, i.e. they are different for each
+ * Note: The {@link #DTSTART}, {@link #DUE} values of instances of recurring
+ * tasks represent the actual instance values, i.e. they are different for each
* instance ({@link #DURATION} is always {@code null}).
+ *
*
- * Also, none of the instances are recurring themselves, so {@link #RRULE}, {@link #RDATE} and {@link #EXDATE} are always {@code null}.
+ * Also, none of the instances are recurring themselves, so {@link #RRULE},
+ * {@link #RDATE} and {@link #EXDATE} are always {@code null}.
+ *
*
* TODO: Insert all instances of recurring tasks.
+ *
*
* The following operations are supported:
+ *
*
+ *
*
Insert
+ *
*
- * Note, the data of an insert must not contain the fields {@link #RRULE}, {@link #RDATE} or {@link #EXDATE}. If the new instance belongs to an existing
- * task the data must contain the fields {@link #ORIGINAL_INSTANCE_ID} and {@link #ORIGINAL_INSTANCE_TIME}. Also note, this table supports writing {@link
- * #DURATION} (if the instance has a {@link #DTSTART}), but reading it back will always return a {@code null} {@link #DURATION} and a non-{@code null}
- * {@link #DUE} date. Reading the task in the tasks table will, however, return the original {@link #DURATION}.
+ * Note, the data of an insert must not contain the fields {@link #RRULE},
+ * {@link #RDATE} or {@link #EXDATE}. If the new instance belongs to an existing
+ * task the data must contain the fields {@link #ORIGINAL_INSTANCE_ID} and
+ * {@link #ORIGINAL_INSTANCE_TIME}. Also note, this table supports writing
+ * {@link #DURATION} (if the instance has a {@link #DTSTART}), but reading it
+ * back will always return a {@code null} {@link #DURATION} and a
+ * non-{@code null} {@link #DUE} date. Reading the task in the tasks table will,
+ * however, return the original {@link #DURATION}.
+ *
*
- * If there already is an instance (with or without override) for the given {@link #ORIGINAL_INSTANCE_ID} and {@link #ORIGINAL_INSTANCE_TIME} an exception
- * is thrown.
+ * If there already is an instance (with or without override) for the given
+ * {@link #ORIGINAL_INSTANCE_ID} and {@link #ORIGINAL_INSTANCE_TIME} an
+ * exception is thrown.
+ *
*
- *
| ORIGINAL_INSTANCE_ID value | Result |
| absent or empty | A new non-recurring task is created with the given
- * values. |
| a valid {@link Tasks} row {@code _ID} | An {@link #RDATE} for the given {@link #ORIGINAL_INSTANCE_TIME} time is added to
- * the given master task, any {@link #EXDATE} for this time is removed. The task is inserted as an override to the given master. No fields are inherited
- * though. {@link #ORIGINAL_INSTANCE_ALLDAY} will be set to {@link #IS_ALLDAY} of the master.
+ *
+ *
+ *
+ * | ORIGINAL_INSTANCE_ID value |
+ * Result |
+ *
+ *
+ * | absent or empty |
+ * A new non-recurring task is created with the given values. |
+ *
+ *
+ * | a valid {@link Tasks} row {@code _ID} |
+ * An {@link #RDATE} for the given {@link #ORIGINAL_INSTANCE_TIME} time is
+ * added to the given master task, any {@link #EXDATE} for this time is removed.
+ * The task is inserted as an override to the given master. No fields are
+ * inherited though. {@link #ORIGINAL_INSTANCE_ALLDAY} will be set to
+ * {@link #IS_ALLDAY} of the master.
*
- * Note, if the given master is non-recurring, this operation will turn it into a recurring task. | | invalid {@link Tasks} row {@code
- * _ID} | An exception is thrown. |
+ * Note, if the given master is non-recurring, this operation will turn it into
+ * a recurring task. |
+ *
+ *
+ * | invalid {@link Tasks} row {@code
+ * _ID} |
+ * An exception is thrown. |
+ *
+ *
+ *
*
+ *
*
Update
+ *
*
- * Note, the data of an update must not contain any fields related to recurrence ({@link #RRULE}, {@link #RDATE}, {@link #EXDATE}, {@link
- * #ORIGINAL_INSTANCE_ID}, {@link #ORIGINAL_INSTANCE_TIME} and {@link #ORIGINAL_INSTANCE_ALLDAY}). Also note, this table supports writing {@link #DURATION}
- * (if the instance has a {@link #DTSTART}), but reading it back will always return a {@code null} {@link #DURATION} and a non-{@code null} {@link #DUE}
- * date. Reading the task in the tasks table will, however, return the original {@link #DURATION}.
+ * Note, the data of an update must not contain any fields related to recurrence
+ * ({@link #RRULE}, {@link #RDATE}, {@link #EXDATE},
+ * {@link #ORIGINAL_INSTANCE_ID}, {@link #ORIGINAL_INSTANCE_TIME} and
+ * {@link #ORIGINAL_INSTANCE_ALLDAY}). Also note, this table supports writing
+ * {@link #DURATION} (if the instance has a {@link #DTSTART}), but reading it
+ * back will always return a {@code null} {@link #DURATION} and a
+ * non-{@code null} {@link #DUE} date. Reading the task in the tasks table will,
+ * however, return the original {@link #DURATION}.
+ *
*
- *
| Target task type | Result |
| Recurring master task | A new override is created with the given data. Note,
- * any fields which are not provided are inherited from the master, except for {@link #DTSTART} and {@link #DUE} which will be inherited from the instance
- * and {@link #DURATION}, {@link #RRULE}, {@link #RDATE} and {@link #EXDATE} which are set to {@code null}. {@link #ORIGINAL_INSTANCE_ID}, {@link
- * #ORIGINAL_INSTANCE_TIME} and {@link #ORIGINAL_INSTANCE_ALLDAY} will be set accordingly. |
| Single instance task | The task is
- * updated with the given values. |
| Recurrence override with existing master | The task is updated with the given values. |
- * | Recurrence override without existing master | The task is updated with the given values. |
+ *
+ *
+ *
+ * | Target task type |
+ * Result |
+ *
+ *
+ * | Recurring master task |
+ * A new override is created with the given data.
+ *
+ * Note, any fields which are not provided are inherited from the master, except
+ * for {@link #DTSTART} and {@link #DUE} which will be inherited from the
+ * instance and {@link #DURATION}, {@link #RRULE}, {@link #RDATE} and
+ * {@link #EXDATE} which are set to {@code null}. {@link #ORIGINAL_INSTANCE_ID},
+ * {@link #ORIGINAL_INSTANCE_TIME} and {@link #ORIGINAL_INSTANCE_ALLDAY} will be
+ * set accordingly. |
+ *
+ *
+ * | Single instance task |
+ * The task is updated with the given values. |
+ *
+ *
+ * | Recurrence override with existing master |
+ * The task is updated with the given values. |
+ *
+ *
+ * | Recurrence override without existing master |
+ * The task is updated with the given values. |
+ *
+ *
+ *
*
+ *
*
Delete
+ *
+ *
+ *
+ *
+ *
+ * | Target task type |
+ * Result |
+ *
+ *
+ * | Recurring master task |
+ * An {@link #EXDATE} for this instance is added, any {@link #RDATE} for
+ * this instance is removed. The instance row is removed.
*
- * | Target task type | Result | | Recurring master task | An {@link #EXDATE} for this instance is added, any {@link
- * #RDATE} for this instance is removed. The instance row is removed. TODO: mark the task deleted if the remaining recurrence set is empty |
- * | Single instance task | The {@link Tasks#_DELETED} flag of the task is set. | | Recurrence override with existing
- * master | The {@link Tasks#_DELETED} flag of the override is set, an {@link #EXDATE} for this instance is added to the master, any {@link #RDATE}
- * for this instance is removed from the master. TODO: mark the master deleted if the remaining recurrence set of the master is empty |
- * | Recurrence override without existing master | The {@link Tasks#_DELETED} flag of the task is set. |
+ * TODO: mark the task deleted if the remaining recurrence set is empty |
+ *
+ *
+ * | Single instance task |
+ * The {@link Tasks#_DELETED} flag of the task is set. |
+ *
+ *
+ * | Recurrence override with existing master |
+ * The {@link Tasks#_DELETED} flag of the override is set, an
+ * {@link #EXDATE} for this instance is added to the master, any {@link #RDATE}
+ * for this instance is removed from the master. TODO: mark the master deleted
+ * if the remaining recurrence set of the master is empty |
+ *
+ *
+ * | Recurrence override without existing master |
+ * The {@link Tasks#_DELETED} flag of the task is set. |
+ *
+ *
*
* @author Yannic Ahrens
* @author Marten Gajda
*/
- public static final class Instances implements TaskColumns, InstanceColumns
- {
+ public static final class Instances implements TaskColumns, InstanceColumns {
/**
- * The name of the account the task belongs to. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The name of the account the task belongs to. This is auto-derived from the
+ * list the task belongs to. Do not write this value here.
+ *
*
* Value: String
- *
+ *
*
* read-only
- *
*/
public static final String ACCOUNT_NAME = TaskLists.ACCOUNT_NAME;
/**
- * The type of the account the task belongs to. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The type of the account the task belongs to. This is auto-derived from the
+ * list the task belongs to. Do not write this value here.
+ *
*
* Value: String
- *
+ *
*
* read-only
- *
*/
public static final String ACCOUNT_TYPE = TaskLists.ACCOUNT_TYPE;
/**
- * The name of the list this task belongs to as integer (0xaarrggbb). This is auto-derived from the list the task belongs to. Do not write this value
- * here.
+ * The name of the list this task belongs to as integer (0xaarrggbb). This is
+ * auto-derived from the list the task belongs to. Do not write this value here.
+ *
*
* Value: String
- *
+ *
*
* read-only
- *
*/
public static final String LIST_NAME = TaskLists.LIST_NAME;
+
/**
- * The color of the list this task belongs to as integer (0xaarrggbb). This is auto-derived from the list the task belongs to. Do not write this value
- * here. To change the color of an individual task use {@code TASK_COLOR} instead.
+ * The color of the list this task belongs to as integer (0xaarrggbb). This is
+ * auto-derived from the list the task belongs to. Do not write this value here.
+ * To change the color of an individual task use {@code TASK_COLOR} instead.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
public static final String LIST_COLOR = TaskLists.LIST_COLOR;
/**
- * The owner of the list this task belongs. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The owner of the list this task belongs. This is auto-derived from the list
+ * the task belongs to. Do not write this value here.
+ *
*
* Value: String
- *
+ *
*
* read-only
- *
*/
public static final String LIST_OWNER = TaskLists.OWNER;
/**
- * The access level of the list this task belongs. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The access level of the list this task belongs. This is auto-derived from the
+ * list the task belongs to. Do not write this value here.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
public static final String LIST_ACCESS_LEVEL = TaskLists.ACCESS_LEVEL;
/**
- * The visibility of the list this task belongs. This is auto-derived from the list the task belongs to. Do not write this value here.
+ * The visibility of the list this task belongs. This is auto-derived from the
+ * list the task belongs to. Do not write this value here.
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
public static final String VISIBLE = "visible";
/**
* Flag indicating that ths is an instance of a recurring task.
+ *
*
* Value: Integer
+ *
*
* read-only
*/
@@ -1224,32 +1330,28 @@ public final class TaskContract
public static final String DEFAULT_SORT_ORDER = INSTANCE_DUE_SORTING;
-
/**
* Get the instances content {@link Uri} using the given authority.
*
* @param authority
- * The authority.
- *
+ * The authority.
* @return A {@link Uri}.
*/
- public static Uri getContentUri(String authority)
- {
+ public static Uri getContentUri(String authority) {
return getUriFactory(authority).getUri(CONTENT_URI_PATH);
}
-
}
-
/**
* Available values in Categories.
+ *
*
- * Categories are per account. It's up to the front-end to ensure consistency of category colors across accounts.
+ * Categories are per account. It's up to the front-end to ensure consistency of
+ * category colors across accounts.
*
* @author Marten Gajda
*/
- public interface CategoriesColumns
- {
+ public interface CategoriesColumns {
String _ID = "_id";
@@ -1262,33 +1364,25 @@ public final class TaskContract
String COLOR = "color";
}
-
- public static final class Categories implements CategoriesColumns
- {
+ public static final class Categories implements CategoriesColumns {
public static final String CONTENT_URI_PATH = "categories";
public static final String DEFAULT_SORT_ORDER = NAME;
-
/**
* Get the categories content {@link Uri} using the given authority.
*
* @param authority
- * The authority.
- *
+ * The authority.
* @return A {@link Uri}.
*/
- public static Uri getContentUri(String authority)
- {
+ public static Uri getContentUri(String authority) {
return getUriFactory(authority).getUri(CONTENT_URI_PATH);
}
-
}
-
- public interface AlarmsColumns
- {
+ public interface AlarmsColumns {
String ALARM_ID = "alarm_id";
String LAST_TRIGGER = "last_trigger";
@@ -1296,31 +1390,23 @@ public final class TaskContract
String NEXT_TRIGGER = "next_trigger";
}
-
- public static final class Alarms implements AlarmsColumns
- {
+ public static final class Alarms implements AlarmsColumns {
public static final String CONTENT_URI_PATH = "alarms";
-
/**
* Get the alarms content {@link Uri} using the given authority.
*
* @param authority
- * The authority.
- *
+ * The authority.
* @return A {@link Uri}.
*/
- public static Uri getContentUri(String authority)
- {
+ public static Uri getContentUri(String authority) {
return getUriFactory(authority).getUri(CONTENT_URI_PATH);
}
-
}
-
- public interface PropertySyncColumns
- {
+ public interface PropertySyncColumns {
String SYNC1 = "prop_sync1";
String SYNC2 = "prop_sync2";
@@ -1338,9 +1424,7 @@ public final class TaskContract
String SYNC8 = "prop_sync8";
}
-
- public interface PropertyColumns
- {
+ public interface PropertyColumns {
String PROPERTY_ID = "property_id";
@@ -1383,112 +1467,98 @@ public final class TaskContract
String DATA15 = "data15";
}
-
- public static final class Properties implements PropertySyncColumns, PropertyColumns
- {
+ public static final class Properties implements PropertySyncColumns, PropertyColumns {
public static final String CONTENT_URI_PATH = "properties";
public static final String DEFAULT_SORT_ORDER = DATA0;
-
/**
* Get the properties content {@link Uri} using the given authority.
*
* @param authority
- * The authority.
- *
+ * The authority.
* @return A {@link Uri}.
*/
- public static Uri getContentUri(String authority)
- {
+ public static Uri getContentUri(String authority) {
return getUriFactory(authority).getUri(CONTENT_URI_PATH);
}
-
}
-
- public interface Property
- {
+ public interface Property {
/**
* Attached documents.
+ *
*
- * Note: Attachments are write-once. To change an attachment you'll have to remove and re-add it.
- *
+ * Note: Attachments are write-once. To change an attachment
+ * you'll have to remove and re-add it.
*
* @author Marten Gajda
*/
- interface Attachment extends PropertyColumns
- {
- /**
- * The mime-type of this property.
- */
+ interface Attachment extends PropertyColumns {
+ /** The mime-type of this property. */
String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/attachment";
/**
* URL of the attachment. This is the link that points to the attached resource.
+ *
*
* Value: String
- *
*/
String URL = DATA1;
/**
* The display name of the attachment, if any.
+ *
*
* Value: String
- *
*/
String DISPLAY_NAME = DATA2;
/**
* Content-type of the attachment.
+ *
*
* Value: String
- *
*/
String FORMAT = DATA3;
/**
* File size of the attachment or -1 if unknown.
+ *
*
* Value: Long
- *
*/
String SIZE = DATA4;
/**
- * A content {@link Uri} that can be used to retrieve the attachment. Sync adapters can set this field if they know how to download the attachment
+ * A content {@link Uri} that can be used to retrieve the attachment. Sync
+ * adapters can set this field if they know how to download the attachment
* without going through the browser.
+ *
*
* Value: String
- *
*/
String CONTENT_URI = DATA5;
-
}
-
- interface Attendee extends PropertyColumns
- {
- /**
- * The mime-type of this property.
- */
+ interface Attendee extends PropertyColumns {
+ /** The mime-type of this property. */
String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/attendee";
/**
* Name of the contact, if known.
+ *
*
* Value: String
- *
*/
String NAME = DATA0;
/**
* Email address of the contact.
+ *
*
* Value: String
- *
*/
String EMAIL = DATA1;
@@ -1499,76 +1569,67 @@ public final class TaskContract
String RSVP = DATA4;
}
-
/**
- * Categories are immutable. For creation is either the category id or name necessary
+ * Categories are immutable. For creation is either the category id or name
+ * necessary
*/
- interface Category extends PropertyColumns
- {
- /**
- * The mime-type of this property.
- */
+ interface Category extends PropertyColumns {
+ /** The mime-type of this property. */
String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/category";
/**
* Row id of the category.
+ *
*
* Value: Long
- *
*/
String CATEGORY_ID = DATA0;
/**
* The name of the category
+ *
*
* Value: String
- *
*/
String CATEGORY_NAME = DATA1;
/**
* The decimal coded color of the category
+ *
*
* Value: Integer
- *
+ *
*
* read-only
- *
*/
String CATEGORY_COLOR = DATA2;
}
-
- interface Comment extends PropertyColumns
- {
- /**
- * The mime-type of this property.
- */
+ interface Comment extends PropertyColumns {
+ /** The mime-type of this property. */
String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/comment";
/**
* Comment text.
+ *
*
* Value: String
- *
*/
String COMMENT = DATA0;
/**
- * Language code of the comment as defined in RFC5646 or null.
+ * Language code of the comment as defined in
+ * RFC5646 or
+ * null.
+ *
*
* Value: String
- *
*/
String LANGUAGE = DATA1;
}
-
- interface Contact extends PropertyColumns
- {
- /**
- * The mime-type of this property.
- */
+ interface Contact extends PropertyColumns {
+ /** The mime-type of this property. */
String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/contact";
String NAME = DATA0;
@@ -1576,78 +1637,70 @@ public final class TaskContract
String LANGUAGE = DATA1;
}
-
/**
* Relations of a task.
+ *
*
- * When writing a relation, exactly one of {@link #RELATED_ID} or {@link #RELATED_UID} must be present. The missing value and {@link
- * #RELATED_CONTENT_URI} will be populated automatically if possible.
+ * When writing a relation, exactly one of {@link #RELATED_ID} or
+ * {@link #RELATED_UID} must be present. The missing value and
+ * {@link #RELATED_CONTENT_URI} will be populated automatically if possible.
+ *
*
* {@link Tasks#PARENT_ID} is updated automatically if possible.
*/
- interface Relation extends PropertyColumns
- {
- /**
- * The mime-type of this property.
- */
+ interface Relation extends PropertyColumns {
+ /** The mime-type of this property. */
String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/relation";
/**
- * The row id of the related task. May be -1 if the property doesn't refer to a task in this database or if it doesn't refer to a task
- * at all.
+ * The row id of the related task. May be -1 if the property
+ * doesn't refer to a task in this database or if it doesn't refer to a task at
+ * all.
+ *
*
* Value: long
- *
*/
String RELATED_ID = DATA1;
/**
* The relation type. This must be one of the {@code RELTYPE_*} values.
+ *
*
* Value: int
- *
*/
String RELATED_TYPE = DATA2;
/**
* The UID of the related object.
+ *
*
* Value: String
- *
*/
String RELATED_UID = DATA3;
/**
- * The content Uri of a related object in another Android content provider, if found.
+ * The content Uri of a related object in another Android content provider, if
+ * found.
+ *
*
* Value: String (URI)
- *
+ *
*
* This field is read-only.
- *
*/
String RELATED_CONTENT_URI = DATA5;
- /**
- * The related object is the parent of the object owning this relation.
- */
+ /** The related object is the parent of the object owning this relation. */
int RELTYPE_PARENT = 0;
- /**
- * The related object is the child of the object owning this relation.
- */
+ /** The related object is the child of the object owning this relation. */
int RELTYPE_CHILD = 1;
- /**
- * The related object is a sibling of the object owning this relation.
- */
+ /** The related object is a sibling of the object owning this relation. */
int RELTYPE_SIBLING = 2;
-
}
-
- interface Alarm extends PropertyColumns
- {
+ interface Alarm extends PropertyColumns {
int ALARM_TYPE_NOTHING = 0;
@@ -1663,53 +1716,51 @@ public final class TaskContract
int ALARM_REFERENCE_START_DATE = 2;
- /**
- * The mime-type of this property.
- */
+ /** The mime-type of this property. */
String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/alarm";
/**
- * Number of minutes from the reference date when the alarm goes off. If the value is < 0 the alarm will go off after the reference date.
+ * Number of minutes from the reference date when the alarm goes off. If the
+ * value is < 0 the alarm will go off after the reference date.
+ *
*
* Value: Integer
- *
*/
String MINUTES_BEFORE = DATA0;
/**
- * The reference date for the alarm. Either {@link #ALARM_REFERENCE_DUE_DATE} or {@link #ALARM_REFERENCE_START_DATE}.
+ * The reference date for the alarm. Either {@link #ALARM_REFERENCE_DUE_DATE} or
+ * {@link #ALARM_REFERENCE_START_DATE}.
+ *
*
* Value: Integer
- *
*/
String REFERENCE = DATA1;
/**
* A message that appears with the alarm.
+ *
*
* Value: String
- *
*/
String MESSAGE = DATA2;
/**
- * The type of the alarm. Use the provided alarm types {@link #ALARM_TYPE_MESSAGE}, {@link #ALARM_TYPE_SOUND}, {@link #ALARM_TYPE_NOTHING},
- * {@link #ALARM_TYPE_EMAIL} and {@link #ALARM_TYPE_SMS}.
+ * The type of the alarm. Use the provided alarm types
+ * {@link #ALARM_TYPE_MESSAGE}, {@link #ALARM_TYPE_SOUND},
+ * {@link #ALARM_TYPE_NOTHING}, {@link #ALARM_TYPE_EMAIL} and
+ * {@link #ALARM_TYPE_SMS}.
+ *
*
* Value: Integer
- *
*/
String ALARM_TYPE = DATA3;
}
-
}
-
- private static synchronized UriFactory getUriFactory(String authority)
- {
+ private static synchronized UriFactory getUriFactory(String authority) {
UriFactory uriFactory = sUriFactories.get(authority);
- if (uriFactory == null)
- {
+ if (uriFactory == null) {
uriFactory = new UriFactory(authority);
uriFactory.addUri(SyncState.CONTENT_URI_PATH);
uriFactory.addUri(TaskLists.CONTENT_URI_PATH);
@@ -1720,9 +1771,7 @@ public final class TaskContract
uriFactory.addUri(Alarms.CONTENT_URI_PATH);
uriFactory.addUri(Properties.CONTENT_URI_PATH);
sUriFactories.put(authority, uriFactory);
-
}
return uriFactory;
}
-
}
diff --git a/opentasks-contract/src/main/java/org/dmfs/tasks/contract/UriFactory.java b/opentasks-contract/src/main/java/org/dmfs/tasks/contract/UriFactory.java
index 0092aca26ac777dd35c987ee402d257072336675..810a4c618edd212f1663540a935003267ddde755 100644
--- a/opentasks-contract/src/main/java/org/dmfs/tasks/contract/UriFactory.java
+++ b/opentasks-contract/src/main/java/org/dmfs/tasks/contract/UriFactory.java
@@ -17,41 +17,28 @@
package org.dmfs.tasks.contract;
import android.net.Uri;
-
import java.util.HashMap;
import java.util.Map;
-
-/**
- * TODO
- */
-public final class UriFactory
-{
+/** TODO */
+public final class UriFactory {
private final String mAuthority;
private final Map mUriMap = new HashMap(16);
-
- UriFactory(String authority)
- {
+ UriFactory(String authority) {
mAuthority = authority;
mUriMap.put(null, Uri.parse("content://" + authority));
}
-
- void addUri(String path)
- {
+ void addUri(String path) {
mUriMap.put(path, Uri.parse("content://" + mAuthority + "/" + path));
}
-
- Uri getUri()
- {
+ Uri getUri() {
return mUriMap.get(null);
}
-
- Uri getUri(String path)
- {
+ Uri getUri(String path) {
return mUriMap.get(path);
}
}
diff --git a/opentasks-provider/build.gradle b/opentasks-provider/build.gradle
index 0ac44f88745014f94678c709a550812479a7a4ac..561b813d1951978ee51c27164d52c69fdc428ef1 100644
--- a/opentasks-provider/build.gradle
+++ b/opentasks-provider/build.gradle
@@ -9,20 +9,21 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 36
-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-
}
+
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
+
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
+
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
diff --git a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderDetachInstancesTest.java b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderDetachInstancesTest.java
index bd824a9a44f5bb0c2ee1841ff5d83c296d25d1a8..f8fba3567972248d57a22cfcf5610dd190cfcdbd 100644
--- a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderDetachInstancesTest.java
+++ b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderDetachInstancesTest.java
@@ -16,13 +16,19 @@
package org.dmfs.provider.tasks;
+import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
+import static org.dmfs.jems.optional.elementary.Absent.absent;
+import static org.junit.Assert.assertThat;
+
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.content.Context;
import android.content.OperationApplicationException;
import android.os.Build;
import android.os.RemoteException;
-
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+import java.util.TimeZone;
import org.dmfs.android.contentpal.Operation;
import org.dmfs.android.contentpal.OperationsQueue;
import org.dmfs.android.contentpal.RowSnapshot;
@@ -73,32 +79,19 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.TimeZone;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
-import static org.dmfs.jems.optional.elementary.Absent.absent;
-import static org.junit.Assert.assertThat;
-
-
/**
* Test {@link TaskProvider} for correctly detaching completed instances.
*
* @author Marten Gajda
*/
@RunWith(AndroidJUnit4.class)
-public class TaskProviderDetachInstancesTest
-{
+public class TaskProviderDetachInstancesTest {
private String mAuthority;
private ContentProviderClient mClient;
private Account mTestAccount = new Account("testname", "testtype");
-
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
Context context = InstrumentationRegistry.getTargetContext();
mAuthority = AuthorityUtil.taskAuthority(context);
mClient = context.getContentResolver().acquireContentProviderClient(mAuthority);
@@ -106,46 +99,44 @@ public class TaskProviderDetachInstancesTest
// Assert that tables are empty:
OperationsQueue queue = new BasicOperationsQueue(mClient);
queue.flush();
- queue.enqueue(new Seq>(
- new AssertEmptyTable<>(new TasksTable(mAuthority)),
+ queue.enqueue(new Seq>(new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new TaskListsTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
queue.flush();
}
-
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
/*
- TODO When Test Orchestration is available, there will be no need for clean up here and check in setUp(), every test method will run in separate instrumentation
- https://android-developers.googleblog.com/2017/07/android-testing-support-library-10-is.html
- https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator
- */
+ * TODO When Test Orchestration is available, there will be no need for clean up
+ * here and check in setUp(), every test method will run in separate
+ * instrumentation
+ * https://android-developers.googleblog.com/2017/07/android-testing-support-
+ * library-10-is.html
+ * https://developer.android.com/training/testing/junit-runner.html#using-
+ * android-test-orchestrator
+ */
// Clear the DB:
BasicOperationsQueue queue = new BasicOperationsQueue(mClient);
queue.enqueue(new SingletonIterable>(new BulkDelete<>(new LocalTaskListsTable(mAuthority))));
queue.flush();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mClient.close();
- }
- else
- {
+ } else {
mClient.release();
}
}
-
/**
- * Test if the first instance of a task with a DTSTART, DUE and an RRULE is correctly detached when completed.
+ * Test if the first instance of a task with a DTSTART, DUE and an RRULE is
+ * correctly detached when completed.
*/
@Test
- public void testRRule() throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException
- {
- RowSnapshot taskList = new VirtualRowSnapshot<>(new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
+ public void testRRule() throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException {
+ RowSnapshot taskList = new VirtualRowSnapshot<>(
+ new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -164,62 +155,57 @@ public class TaskProviderDetachInstancesTest
DateTime localDue = due.shiftTimeZone(TimeZone.getDefault());
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX))))
- ));
+ queue.enqueue(new Seq<>(new Put<>(taskList, new EmptyRowData<>()), new Put<>(task, new Composite<>(
+ new TimeData<>(start, due),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX))))));
queue.flush();
assertThat(new Seq<>(
- // update the first non-closed instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ),
+ // update the first non-closed instance
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
+ new AllOf<>(new ReferringTo<>(
+ Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))),
resultsIn(queue,
/*
- * We expect three tasks:
- * - the original master with updated RRULE, DTSTART and DUE
- * - a deleted instance
- * - a detached task
+ * We expect three tasks: - the original master with updated RRULE, DTSTART and
+ * DUE - a deleted instance - a detached task
*/
// the original master
new Assert<>(task,
- new Composite<>(
- new TimeData<>(start.addDuration(day), due.addDuration(day)),
+ new Composite<>(new TimeData<>(start.addDuration(day), due.addDuration(day)),
new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=4"))),
- // there is one instance referring to the master (the old second instance, now first)
+ // there is one instance referring to the master (the old second instance, now
+ // first)
new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
// the detached task instance:
- new Counted<>(1, new BulkAssert<>(new Synced<>(mTestAccount, instancesTable),
- new Composite<>(
- new InstanceTestData(localStart, localDue, absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
- new Not<>(new ReferringTo<>(Instances.TASK_ID, task)))),
+ new Counted<>(1,
+ new BulkAssert<>(new Synced<>(mTestAccount, instancesTable),
+ new Composite<>(new InstanceTestData(localStart, localDue, absent(), -1),
+ new CharSequenceRowData<>(Tasks.STATUS,
+ String.valueOf(Tasks.STATUS_COMPLETED))),
+ new Not<>(new ReferringTo<>(Instances.TASK_ID, task)))),
// the deleted task (doesn't have an instance)
- new Counted<>(1, new BulkAssert<>(new Synced<>(mTestAccount, new TasksTable(mAuthority)),
- new Composite<>(new TimeData<>(start, due)),
- new AllOf<>(
- new ReferringTo<>(Tasks.ORIGINAL_INSTANCE_ID, task),
- new EqArg<>(Tasks._DELETED, 1)))),
+ new Counted<>(1,
+ new BulkAssert<>(new Synced<>(mTestAccount, new TasksTable(mAuthority)),
+ new Composite<>(new TimeData<>(start, due)),
+ new AllOf<>(new ReferringTo<>(Tasks.ORIGINAL_INSTANCE_ID, task),
+ new EqArg<>(Tasks._DELETED, 1)))),
// the former 2nd instance (now first)
new AssertRelated<>(new Synced<>(mTestAccount, instancesTable), Instances.TASK_ID, task,
new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 0),
new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp()))));
}
-
/**
- * Test if two instances of a task with a DTSTART, DUE and an RRULE are detached correctly.
+ * Test if two instances of a task with a DTSTART, DUE and an RRULE are detached
+ * correctly.
*/
@Test
- public void testRRuleCompleteAll() throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException
- {
- RowSnapshot taskList = new VirtualRowSnapshot<>(new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
+ public void testRRuleCompleteAll()
+ throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException {
+ RowSnapshot taskList = new VirtualRowSnapshot<>(
+ new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -238,89 +224,77 @@ public class TaskProviderDetachInstancesTest
DateTime localDue = due.shiftTimeZone(TimeZone.getDefault());
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TitleData("Test-Task"),
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=2", RecurrenceRule.RfcMode.RFC2445_LAX)))),
- // complete the first non-closed instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ));
+ queue.enqueue(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ new Put<>(task, new Composite<>(new TitleData("Test-Task"), new TimeData<>(start, due),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;COUNT=2", RecurrenceRule.RfcMode.RFC2445_LAX)))),
+ // complete the first non-closed instance
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
+ new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
+ new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))));
queue.flush();
Synced tasksTable = new Synced<>(mTestAccount, new TasksTable(mAuthority));
Synced syncedInstances = new Synced<>(mTestAccount, instancesTable);
assertThat(new Seq<>(
- // update the second instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ),
+ // update the second instance
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
+ new AllOf<>(new ReferringTo<>(
+ Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))),
resultsIn(queue,
/*
- * We expect five tasks:
- * - the original master with updated RRULE, DTSTART and DUE, deleted
- * - a completed and deleted overrides for the first and second instance
- * - a detached first and second instance
+ * We expect five tasks: - the original master with updated RRULE, DTSTART and
+ * DUE, deleted - a completed and deleted overrides for the first and second
+ * instance - a detached first and second instance
*/
// the original master
- new Assert<>(task,
- new Composite<>(
- // points to former second instance before being deleted
- new TimeData<>(start.addDuration(day), due.addDuration(day)),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=1"),
- new CharSequenceRowData<>(Tasks._DELETED, "1"))),
- // there is no instance referring to the master because it has been fully completed (and deleted)
+ new Assert<>(task, new Composite<>(
+ // points to former second instance before being deleted
+ new TimeData<>(start.addDuration(day), due.addDuration(day)),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=1"),
+ new CharSequenceRowData<>(Tasks._DELETED, "1"))),
+ // there is no instance referring to the master because it has been fully
+ // completed (and
+ // deleted)
new Counted<>(0, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
// the first detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(localStart, localDue, absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
- new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, start.getTimestamp()),
- new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
+ new Counted<>(1,
+ new BulkAssert<>(syncedInstances,
+ new Composite<>(new InstanceTestData(localStart, localDue, absent(), -1),
+ new CharSequenceRowData<>(Tasks.STATUS,
+ String.valueOf(Tasks.STATUS_COMPLETED))),
+ new AllOf<>(new EqArg<>(Instances.INSTANCE_START, start.getTimestamp()),
+ new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// the second detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(second, second.addDuration(new Duration(1, 0, 3600)), absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
- new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, second.getTimestamp()),
+ new Counted<>(1, new BulkAssert<>(syncedInstances, new Composite<>(
+ new InstanceTestData(second, second.addDuration(new Duration(1, 0, 3600)), absent(),
+ -1),
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
+ new AllOf<>(new EqArg<>(Instances.INSTANCE_START, second.getTimestamp()),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// two instances total, both completed
new Counted<>(2,
- new BulkAssert<>(
- syncedInstances,
+ new BulkAssert<>(syncedInstances,
new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED)),
new AnyOf<>())),
// five tasks in total
- new Counted<>(5,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new AnyOf<>())),
+ new Counted<>(5, new BulkAssert<>(tasksTable, new TitleData("Test-Task"), new AnyOf<>())),
// three deleted tasks in total
- new Counted<>(3,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new EqArg<>(Tasks._DELETED, 1)))));
+ new Counted<>(3, new BulkAssert<>(tasksTable, new TitleData("Test-Task"),
+ new EqArg<>(Tasks._DELETED, 1)))));
}
-
/**
- * Test if two instances of a task with a DTSTART, DUE, RRULE and RDATE are detached correctly.
+ * Test if two instances of a task with a DTSTART, DUE, RRULE and RDATE are
+ * detached correctly.
*/
@Test
- public void testRRuleRDateCompleteFirstTwo() throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException
- {
- RowSnapshot taskList = new VirtualRowSnapshot<>(new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
+ public void testRRuleRDateCompleteFirstTwo()
+ throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException {
+ RowSnapshot taskList = new VirtualRowSnapshot<>(
+ new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -339,110 +313,91 @@ public class TaskProviderDetachInstancesTest
DateTime localDue = due.shiftTimeZone(TimeZone.getDefault());
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ queue.enqueue(new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new TitleData("Test-Task"),
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;INTERVAL=2;COUNT=2", RecurrenceRule.RfcMode.RFC2445_LAX)),
- new RDatesTaskData(
- new Seq<>(
- DateTime.parse("20180103T123456Z"),
- DateTime.parse("20180105T123456Z"),
- DateTime.parse("20180107T123456Z"))))),
+ new Composite<>(new TitleData("Test-Task"), new TimeData<>(start, due),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;INTERVAL=2;COUNT=2",
+ RecurrenceRule.RfcMode.RFC2445_LAX)),
+ new RDatesTaskData(new Seq<>(DateTime.parse("20180103T123456Z"),
+ DateTime.parse("20180105T123456Z"), DateTime.parse("20180107T123456Z"))))),
// update the first non-closed instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ));
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED), new AllOf<>(
+ new ReferringTo<>(Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))));
queue.flush();
Synced tasksTable = new Synced<>(mTestAccount, new TasksTable(mAuthority));
Synced syncedInstances = new Synced<>(mTestAccount, instancesTable);
assertThat(new Seq<>(
- // update the second instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ),
+ // update the second instance
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
+ new AllOf<>(new ReferringTo<>(
+ Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))),
resultsIn(queue,
/*
- * We expect five tasks:
- * - the original master with updated RRULE, RDATES, DTSTART and DUE, deleted
- * - completed and deleted overrides for the first and second instance
- * - a detached first and second instance
+ * We expect five tasks: - the original master with updated RRULE, RDATES,
+ * DTSTART and DUE, deleted - completed and deleted overrides for the first and
+ * second instance - a detached first and second instance
*/
// the first detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(DateTime.parse("20180103T123456Z"), DateTime.parse("20180103T133456Z"), absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
+ new Counted<>(1, new BulkAssert<>(syncedInstances, new Composite<>(
+ new InstanceTestData(DateTime.parse("20180103T123456Z"),
+ DateTime.parse("20180103T133456Z"), absent(), -1),
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, DateTime.parse("20180103T123456Z").getTimestamp()),
+ new EqArg<>(Instances.INSTANCE_START,
+ DateTime.parse("20180103T123456Z").getTimestamp()),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// the original master has been updated
- new Assert<>(task,
- new Composite<>(
- // points to former third instance before being deleted
- new TimeData<>(start.addDuration(day).addDuration(day), due.addDuration(day).addDuration(day)),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;INTERVAL=2;COUNT=1"),
- new CharSequenceRowData<>(Tasks._DELETED, "0"),
- new RDatesTaskData(
- new Seq<>(
- DateTime.parse("20180105T123456Z"),
- DateTime.parse("20180107T123456Z"))))),
+ new Assert<>(task, new Composite<>(
+ // points to former third instance before being deleted
+ new TimeData<>(start.addDuration(day).addDuration(day),
+ due.addDuration(day).addDuration(day)),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;INTERVAL=2;COUNT=1"),
+ new CharSequenceRowData<>(Tasks._DELETED, "0"),
+ new RDatesTaskData(new Seq<>(DateTime.parse("20180105T123456Z"),
+ DateTime.parse("20180107T123456Z"))))),
// there is one instance referring to the master
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new CharSequenceRowData<>(Instances.INSTANCE_ORIGINAL_TIME,
- String.valueOf(DateTime.parse("20180105T123456Z").getTimestamp())))),
+ new Counted<>(1,
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new CharSequenceRowData<>(Instances.INSTANCE_ORIGINAL_TIME,
+ String.valueOf(DateTime.parse("20180105T123456Z").getTimestamp())))),
// the second detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(start, due, absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
- new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, start.getTimestamp()),
- new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
+ new Counted<>(1,
+ new BulkAssert<>(syncedInstances,
+ new Composite<>(new InstanceTestData(start, due, absent(), -1),
+ new CharSequenceRowData<>(Tasks.STATUS,
+ String.valueOf(Tasks.STATUS_COMPLETED))),
+ new AllOf<>(new EqArg<>(Instances.INSTANCE_START, start.getTimestamp()),
+ new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// two completed instances, neither of them referring to the master
new Counted<>(2,
- new BulkAssert<>(
- syncedInstances,
+ new BulkAssert<>(syncedInstances,
new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED)),
- new AllOf<>(
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, -1),
+ new AllOf<>(new EqArg<>(Instances.DISTANCE_FROM_CURRENT, -1),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// one incomplete instance , the first instance of the new master
- new Counted<>(1,
- new BulkAssert<>(
- syncedInstances,
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_NEEDS_ACTION)),
- new AllOf<>(
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0),
- new ReferringTo<>(Instances.TASK_ID, task)))),
- // five tasks in total (two deleted overrides, two detached ones and the new master)
- new Counted<>(5,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new AnyOf<>())),
+ new Counted<>(1, new BulkAssert<>(syncedInstances,
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_NEEDS_ACTION)),
+ new AllOf<>(new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0),
+ new ReferringTo<>(Instances.TASK_ID, task)))),
+ // five tasks in total (two deleted overrides, two detached ones and the new
+ // master)
+ new Counted<>(5, new BulkAssert<>(tasksTable, new TitleData("Test-Task"), new AnyOf<>())),
// two deleted tasks in total (the old overrides)
- new Counted<>(2,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new EqArg<>(Tasks._DELETED, 1)))));
+ new Counted<>(2, new BulkAssert<>(tasksTable, new TitleData("Test-Task"),
+ new EqArg<>(Tasks._DELETED, 1)))));
}
-
/**
- * Test if two instances of a task with a DTSTART, DUE, RRULE, RDATE and EXDATE are detached correctly.
+ * Test if two instances of a task with a DTSTART, DUE, RRULE, RDATE and EXDATE
+ * are detached correctly.
*/
@Test
- public void testRRuleRDateCompleteWithExdates() throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException
- {
- RowSnapshot taskList = new VirtualRowSnapshot<>(new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
+ public void testRRuleRDateCompleteWithExdates()
+ throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException {
+ RowSnapshot taskList = new VirtualRowSnapshot<>(
+ new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -461,94 +416,77 @@ public class TaskProviderDetachInstancesTest
DateTime localDue = due.shiftTimeZone(TimeZone.getDefault());
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TitleData("Test-Task"),
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;INTERVAL=2;COUNT=2", RecurrenceRule.RfcMode.RFC2445_LAX)),
- new RDatesTaskData(
- new Seq<>(
- DateTime.parse("20180105T123456Z"),
- DateTime.parse("20180107T123456Z"))),
- new ExDatesTaskData(
- new Seq<>(
- DateTime.parse("20180104T123456Z"),
- DateTime.parse("20180105T123456Z"))))),
+ queue.enqueue(new Seq<>(new Put<>(taskList, new EmptyRowData<>()), new Put<>(task, new Composite<>(
+ new TitleData("Test-Task"), new TimeData<>(start, due),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;INTERVAL=2;COUNT=2", RecurrenceRule.RfcMode.RFC2445_LAX)),
+ new RDatesTaskData(new Seq<>(DateTime.parse("20180105T123456Z"), DateTime.parse("20180107T123456Z"))),
+ new ExDatesTaskData(
+ new Seq<>(DateTime.parse("20180104T123456Z"), DateTime.parse("20180105T123456Z"))))),
// update the first non-closed instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ));
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED), new AllOf<>(
+ new ReferringTo<>(Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))));
queue.flush();
Synced tasksTable = new Synced<>(mTestAccount, new TasksTable(mAuthority));
Synced syncedInstances = new Synced<>(mTestAccount, instancesTable);
assertThat(new Seq<>(
- // update the second instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ),
+ // update the second instance
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
+ new AllOf<>(new ReferringTo<>(
+ Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))),
resultsIn(queue,
/*
- * We expect five tasks:
- * - the original master deleted
- * - completed and deleted overrides for the first and second instance
- * - detached first and second instances
+ * We expect five tasks: - the original master deleted - completed and deleted
+ * overrides for the first and second instance - detached first and second
+ * instances
*/
// the first detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(DateTime.parse("20180106T123456Z"), DateTime.parse("20180106T133456Z"), absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
+ new Counted<>(1, new BulkAssert<>(syncedInstances, new Composite<>(
+ new InstanceTestData(DateTime.parse("20180106T123456Z"),
+ DateTime.parse("20180106T133456Z"), absent(), -1),
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, DateTime.parse("20180106T123456Z").getTimestamp()),
+ new EqArg<>(Instances.INSTANCE_START,
+ DateTime.parse("20180106T123456Z").getTimestamp()),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// the original master has been deleted
new Counted<>(0, new Assert<>(task, new Composite<>(new EmptyRowData<>()))),
// there is no instance referring to the master
new Counted<>(0, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
// the second detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(DateTime.parse("20180107T123456Z"), DateTime.parse("20180107T133456Z"), absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
+ new Counted<>(1, new BulkAssert<>(syncedInstances, new Composite<>(
+ new InstanceTestData(DateTime.parse("20180107T123456Z"),
+ DateTime.parse("20180107T133456Z"), absent(), -1),
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, DateTime.parse("20180107T123456Z").getTimestamp()),
+ new EqArg<>(Instances.INSTANCE_START,
+ DateTime.parse("20180107T123456Z").getTimestamp()),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// two completed instances, neither of them referring to the master
new Counted<>(2,
- new BulkAssert<>(
- syncedInstances,
+ new BulkAssert<>(syncedInstances,
new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED)),
- new AllOf<>(
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, -1),
+ new AllOf<>(new EqArg<>(Instances.DISTANCE_FROM_CURRENT, -1),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
- // five tasks in total (two deleted overrides, two detached ones and the old master)
- new Counted<>(5,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new AnyOf<>())),
+ // five tasks in total (two deleted overrides, two detached ones and the old
+ // master)
+ new Counted<>(5, new BulkAssert<>(tasksTable, new TitleData("Test-Task"), new AnyOf<>())),
// three deleted tasks in total (the old overrides and the old master)
- new Counted<>(3,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new EqArg<>(Tasks._DELETED, 1)))));
+ new Counted<>(3, new BulkAssert<>(tasksTable, new TitleData("Test-Task"),
+ new EqArg<>(Tasks._DELETED, 1)))));
}
-
/**
- * Test if two instances of a task with a DTSTART, DUE, RRULE, RDATE and EXDATE are detached correctly.
+ * Test if two instances of a task with a DTSTART, DUE, RRULE, RDATE and EXDATE
+ * are detached correctly.
*/
@Test
- public void testRRuleRDateCompleteOnlyRRuleInstances() throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException
- {
- RowSnapshot taskList = new VirtualRowSnapshot<>(new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
+ public void testRRuleRDateCompleteOnlyRRuleInstances()
+ throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException {
+ RowSnapshot taskList = new VirtualRowSnapshot<>(
+ new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -567,98 +505,84 @@ public class TaskProviderDetachInstancesTest
DateTime localDue = due.shiftTimeZone(TimeZone.getDefault());
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TitleData("Test-Task"),
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;INTERVAL=2;COUNT=2", RecurrenceRule.RfcMode.RFC2445_LAX)),
- new RDatesTaskData(
- new Seq<>(
- DateTime.parse("20180105T123456Z"),
- DateTime.parse("20180107T123456Z"))),
- new ExDatesTaskData(
- new Seq<>(
- DateTime.parse("20180104T123456Z")))))
-/* // update the first non-closed instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))*/
+ queue.enqueue(new Seq<>(new Put<>(taskList, new EmptyRowData<>()), new Put<>(task, new Composite<>(
+ new TitleData("Test-Task"), new TimeData<>(start, due),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;INTERVAL=2;COUNT=2", RecurrenceRule.RfcMode.RFC2445_LAX)),
+ new RDatesTaskData(new Seq<>(DateTime.parse("20180105T123456Z"), DateTime.parse("20180107T123456Z"))),
+ new ExDatesTaskData(new Seq<>(DateTime.parse("20180104T123456Z")))))
+ /*
+ * // update the first non-closed instance new BulkUpdate<>(instancesTable, new
+ * StatusData<>(Tasks.STATUS_COMPLETED), new AllOf<>(new
+ * ReferringTo<>(Instances.TASK_ID, task), new
+ * EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
+ */
));
queue.flush();
Synced tasksTable = new Synced<>(mTestAccount, new TasksTable(mAuthority));
Synced syncedInstances = new Synced<>(mTestAccount, instancesTable);
assertThat(new Seq<>(
- // update the second instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ),
+ // update the second instance
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
+ new AllOf<>(new ReferringTo<>(
+ Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))),
resultsIn(queue,
/*
- * We expect five tasks:
- * - the original master deleted
- * - completed and deleted overrides for the first and second instance
- * - detached first and second instances
+ * We expect five tasks: - the original master deleted - completed and deleted
+ * overrides for the first and second instance - detached first and second
+ * instances
*/
// the first detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(DateTime.parse("20180105T123456Z"), DateTime.parse("20180105T133456Z"), absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
+ new Counted<>(1, new BulkAssert<>(syncedInstances, new Composite<>(
+ new InstanceTestData(DateTime.parse("20180105T123456Z"),
+ DateTime.parse("20180105T133456Z"), absent(), -1),
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, DateTime.parse("20180105T123456Z").getTimestamp()),
+ new EqArg<>(Instances.INSTANCE_START,
+ DateTime.parse("20180105T123456Z").getTimestamp()),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// the original master has been updated
new Assert<>(task,
new Composite<>(
- new TimeData<>(DateTime.parse("20180106T123456Z"), DateTime.parse("20180106T133456Z")),
+ new TimeData<>(DateTime.parse("20180106T123456Z"),
+ DateTime.parse("20180106T133456Z")),
new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;INTERVAL=2;COUNT=1"),
new CharSequenceRowData<>(Tasks._DELETED, "0"),
- new RDatesTaskData(
- new Seq<>(
- DateTime.parse("20180107T123456Z"))))),
+ new RDatesTaskData(new Seq<>(DateTime.parse("20180107T123456Z"))))),
// the second detached task instance:
- /* new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(DateTime.parse("20180106T123456Z"), DateTime.parse("20180106T133456Z"), absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
- new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, DateTime.parse("20180106T123456Z").getTimestamp()),
- new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),*/
+ /*
+ * new Counted<>(1, new BulkAssert<>(syncedInstances, new Composite<>( new
+ * InstanceTestData(DateTime.parse("20180106T123456Z"),
+ * DateTime.parse("20180106T133456Z"), absent(), -1), new
+ * CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
+ * new AllOf<>( new EqArg<>(Instances.INSTANCE_START,
+ * DateTime.parse("20180106T123456Z").getTimestamp()), new Not<>(new
+ * ReferringTo<>(Instances.TASK_ID, task))))),
+ */
// one completed instance, not referring to the master
new Counted<>(1,
- new BulkAssert<>(
- syncedInstances,
+ new BulkAssert<>(syncedInstances,
new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED)),
- new AllOf<>(
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, -1),
+ new AllOf<>(new EqArg<>(Instances.DISTANCE_FROM_CURRENT, -1),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// three tasks in total (one deleted override, one detached one and the master)
- new Counted<>(3,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new AnyOf<>())),
+ new Counted<>(3, new BulkAssert<>(tasksTable, new TitleData("Test-Task"), new AnyOf<>())),
// three deleted tasks in total (the old overrides and the old master)
- new Counted<>(1,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new EqArg<>(Tasks._DELETED, 1)))));
+ new Counted<>(1, new BulkAssert<>(tasksTable, new TitleData("Test-Task"),
+ new EqArg<>(Tasks._DELETED, 1)))));
}
-
/**
- * Test if two all-day instances of a task with a DTSTART, DUE, RRULE, RDATE and EXDATE are detached correctly.
+ * Test if two all-day instances of a task with a DTSTART, DUE, RRULE, RDATE and
+ * EXDATE are detached correctly.
*/
@Test
- public void testRRuleRDateCompleteWithExdatesAllDay() throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException
- {
- RowSnapshot taskList = new VirtualRowSnapshot<>(new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
+ public void testRRuleRDateCompleteWithExdatesAllDay()
+ throws InvalidRecurrenceRuleException, RemoteException, OperationApplicationException {
+ RowSnapshot taskList = new VirtualRowSnapshot<>(
+ new Synced<>(mTestAccount, new TaskListsTable(mAuthority)));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -669,84 +593,64 @@ public class TaskProviderDetachInstancesTest
Duration day = new Duration(1, 1, 0);
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TitleData("Test-Task"),
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;INTERVAL=2;COUNT=2", RecurrenceRule.RfcMode.RFC2445_LAX)),
- new RDatesTaskData(
- new Seq<>(
- DateTime.parse("20180105"),
- DateTime.parse("20180107"))),
- new ExDatesTaskData(
- new Seq<>(
- DateTime.parse("20180104"),
- DateTime.parse("20180105"))))),
+ queue.enqueue(new Seq<>(new Put<>(taskList, new EmptyRowData<>()), new Put<>(task,
+ new Composite<>(new TitleData("Test-Task"), new TimeData<>(start, due),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;INTERVAL=2;COUNT=2",
+ RecurrenceRule.RfcMode.RFC2445_LAX)),
+ new RDatesTaskData(new Seq<>(DateTime.parse("20180105"), DateTime.parse("20180107"))),
+ new ExDatesTaskData(new Seq<>(DateTime.parse("20180104"), DateTime.parse("20180105"))))),
// update the first non-closed instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ));
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED), new AllOf<>(
+ new ReferringTo<>(Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))));
queue.flush();
Synced tasksTable = new Synced<>(mTestAccount, new TasksTable(mAuthority));
Synced syncedInstances = new Synced<>(mTestAccount, instancesTable);
assertThat(new Seq<>(
- // update the second instance
- new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))
- ),
+ // update the second instance
+ new BulkUpdate<>(instancesTable, new StatusData<>(Tasks.STATUS_COMPLETED),
+ new AllOf<>(new ReferringTo<>(
+ Instances.TASK_ID, task), new EqArg<>(Instances.DISTANCE_FROM_CURRENT, 0)))),
resultsIn(queue,
/*
- * We expect five tasks:
- * - the original master deleted
- * - completed and deleted overrides for the first and second instance
- * - detached first and second instances
+ * We expect five tasks: - the original master deleted - completed and deleted
+ * overrides for the first and second instance - detached first and second
+ * instances
*/
// the first detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(DateTime.parse("20180106"), DateTime.parse("20180107"), absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
+ new Counted<>(1, new BulkAssert<>(syncedInstances, new Composite<>(
+ new InstanceTestData(DateTime.parse("20180106"), DateTime.parse("20180107"), absent(),
+ -1),
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, DateTime.parse("20180106").getTimestamp()),
+ new EqArg<>(Instances.INSTANCE_START,
+ DateTime.parse("20180106").getTimestamp()),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// the original master has been deleted
new Counted<>(0, new Assert<>(task, new Composite<>(new EmptyRowData<>()))),
// there is no instance referring to the master
new Counted<>(0, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
// the second detached task instance:
- new Counted<>(1, new BulkAssert<>(syncedInstances,
- new Composite<>(
- new InstanceTestData(DateTime.parse("20180107"), DateTime.parse("20180108"), absent(), -1),
- new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
+ new Counted<>(1, new BulkAssert<>(syncedInstances, new Composite<>(
+ new InstanceTestData(DateTime.parse("20180107"), DateTime.parse("20180108"), absent(),
+ -1),
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED))),
new AllOf<>(
- new EqArg<>(Instances.INSTANCE_START, DateTime.parse("20180107").getTimestamp()),
+ new EqArg<>(Instances.INSTANCE_START,
+ DateTime.parse("20180107").getTimestamp()),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
// two completed instances, neither of them referring to the master
new Counted<>(2,
- new BulkAssert<>(
- syncedInstances,
+ new BulkAssert<>(syncedInstances,
new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED)),
- new AllOf<>(
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, -1),
+ new AllOf<>(new EqArg<>(Instances.DISTANCE_FROM_CURRENT, -1),
new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
- // five tasks in total (two deleted overrides, two detached ones and the old master)
- new Counted<>(5,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new AnyOf<>())),
+ // five tasks in total (two deleted overrides, two detached ones and the old
+ // master)
+ new Counted<>(5, new BulkAssert<>(tasksTable, new TitleData("Test-Task"), new AnyOf<>())),
// three deleted tasks in total (the old overrides and the old master)
- new Counted<>(3,
- new BulkAssert<>(
- tasksTable,
- new TitleData("Test-Task"),
- new EqArg<>(Tasks._DELETED, 1)))));
+ new Counted<>(3, new BulkAssert<>(tasksTable, new TitleData("Test-Task"),
+ new EqArg<>(Tasks._DELETED, 1)))));
}
-
}
diff --git a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderInstancesTest.java b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderInstancesTest.java
index af12ef365988b7422e13cd56b06c513e83cf9a0e..d3902b39a98d079c7338267cb02e0879038c1b60 100644
--- a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderInstancesTest.java
+++ b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderInstancesTest.java
@@ -16,6 +16,9 @@
package org.dmfs.provider.tasks;
+import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
+import static org.junit.Assert.assertThat;
+
import android.content.ContentProviderClient;
import android.content.Context;
import android.content.OperationApplicationException;
@@ -23,7 +26,6 @@ import android.os.Build;
import android.os.RemoteException;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
-
import org.dmfs.android.contentpal.Operation;
import org.dmfs.android.contentpal.OperationsQueue;
import org.dmfs.android.contentpal.RowSnapshot;
@@ -62,73 +64,61 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
-import static org.junit.Assert.assertThat;
-
-
/**
- * Tests for {@link TaskProvider}. These tests check various operations on the instances table.
+ * Tests for {@link TaskProvider}. These tests check various operations on the
+ * instances table.
*
* @author Gabor Keszthelyi
* @author Marten Gajda
*/
@RunWith(AndroidJUnit4.class)
-public class TaskProviderInstancesTest
-{
+public class TaskProviderInstancesTest {
private String mAuthority;
private Context mContext;
private ContentProviderClient mClient;
-
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
mContext = InstrumentationRegistry.getTargetContext();
mAuthority = AuthorityUtil.taskAuthority(mContext);
mClient = mContext.getContentResolver().acquireContentProviderClient(mAuthority);
// Assert that tables are empty:
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new AssertEmptyTable<>(new TasksTable(mAuthority)),
+ queue.enqueue(new Seq>(new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new TaskListsTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
queue.flush();
}
-
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
/*
- TODO When Test Orchestration is available, there will be no need for clean up here and check in setUp(), every test method will run in separate instrumentation
- https://android-developers.googleblog.com/2017/07/android-testing-support-library-10-is.html
- https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator
- */
+ * TODO When Test Orchestration is available, there will be no need for clean up
+ * here and check in setUp(), every test method will run in separate
+ * instrumentation
+ * https://android-developers.googleblog.com/2017/07/android-testing-support-
+ * library-10-is.html
+ * https://developer.android.com/training/testing/junit-runner.html#using-
+ * android-test-orchestrator
+ */
// Clear the DB:
BasicOperationsQueue queue = new BasicOperationsQueue(mClient);
queue.enqueue(new SingletonIterable>(new BulkDelete<>(new LocalTaskListsTable(mAuthority))));
queue.flush();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mClient.close();
- }
- else
- {
+ } else {
mClient.release();
}
}
-
- /**
- * Create a single instance.
- */
+ /** Create a single instance. */
@Ignore("Inserting instances is currently unsupported.")
@Test
- public void testInsertSingleInstance()
- {
+ public void testInsertSingleInstance() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot instance = new VirtualRowSnapshot<>(new InstanceTable(mAuthority));
@@ -136,30 +126,23 @@ public class TaskProviderInstancesTest
// create a local list
new Put<>(taskList, new NameData("list1")),
// insert a new task straight into the instances table
- new Put<>(instance, new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1")))
-
- ), resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- // the task list contains exactly one task with the title "task1"
- new Counted<>(1, new BulkAssert<>(new TasksTable(mAuthority))),
- new AssertRelated<>(new TasksTable(mAuthority), Tasks.LIST_ID, taskList,
- new Composite<>(
- new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
- // the instances table contains one instance
- new Counted<>(1, new BulkAssert<>(new InstanceTable(mAuthority))),
- // the instances table contains the given instance
- new Assert<>(instance, new Composite<>(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TITLE, "task1")))));
+ new Put<>(instance,
+ new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1")))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ // the task list contains exactly one task with the title "task1"
+ new Counted<>(1, new BulkAssert<>(new TasksTable(mAuthority))),
+ new AssertRelated<>(new TasksTable(mAuthority), Tasks.LIST_ID, taskList,
+ new Composite<>(new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
+ // the instances table contains one instance
+ new Counted<>(1, new BulkAssert<>(new InstanceTable(mAuthority))),
+ // the instances table contains the given instance
+ new Assert<>(instance, new Composite<>(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TITLE, "task1")))));
}
-
- /**
- * Create a single instance and update it.
- */
+ /** Create a single instance and update it. */
@Test
- public void testUpdateSingleInstance()
- {
+ public void testUpdateSingleInstance() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TasksTable(mAuthority));
@@ -167,37 +150,29 @@ public class TaskProviderInstancesTest
// create a local list
new Put<>(taskList, new NameData("list1")),
// insert a new task straight into the instances table
- new Put<>(task, new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
+ new Put<>(task,
+ new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
// update the instance
- new BulkUpdate<>(
- new InstanceTable(mAuthority),
- new CharSequenceRowData<>(Tasks.TITLE, "Updated"),
- new ReferringTo<>(Instances.TASK_ID, task))
- ), resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- // the task list contains exactly one task with the title "Updated"
- new Counted<>(1, new BulkAssert<>(new TasksTable(mAuthority))),
- new AssertRelated<>(new TasksTable(mAuthority), Tasks.LIST_ID, taskList,
- new Composite<>(
- new CharSequenceRowData<>(Tasks.TITLE, "Updated"))),
- // the instances table contains one instance
- new Counted<>(1, new BulkAssert<>(new InstanceTable(mAuthority))),
- // the instances table contains the given instance
- new Counted<>(1, new BulkAssert<>(
- new InstanceTable(mAuthority),
- new Composite<>(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TITLE, "Updated")),
- new ReferringTo<>(Instances.TASK_ID, task)))));
+ new BulkUpdate<>(new InstanceTable(mAuthority), new CharSequenceRowData<>(Tasks.TITLE, "Updated"),
+ new ReferringTo<>(Instances.TASK_ID, task))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ // the task list contains exactly one task with the title "Updated"
+ new Counted<>(1, new BulkAssert<>(new TasksTable(mAuthority))),
+ new AssertRelated<>(new TasksTable(mAuthority), Tasks.LIST_ID, taskList,
+ new Composite<>(new CharSequenceRowData<>(Tasks.TITLE, "Updated"))),
+ // the instances table contains one instance
+ new Counted<>(1, new BulkAssert<>(new InstanceTable(mAuthority))),
+ // the instances table contains the given instance
+ new Counted<>(1,
+ new BulkAssert<>(new InstanceTable(mAuthority),
+ new Composite<>(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TITLE, "Updated")),
+ new ReferringTo<>(Instances.TASK_ID, task)))));
}
-
- /**
- * Create a single instance and complete it.
- */
+ /** Create a single instance and complete it. */
@Test
- public void testCompleteSingleInstance()
- {
+ public void testCompleteSingleInstance() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TasksTable(mAuthority));
@@ -205,37 +180,30 @@ public class TaskProviderInstancesTest
// create a local list
new Put<>(taskList, new NameData("list1")),
// insert a new task straight into the instances table
- new Put<>(task, new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
+ new Put<>(task,
+ new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
// update the instance status
- new BulkUpdate<>(
- new InstanceTable(mAuthority),
+ new BulkUpdate<>(new InstanceTable(mAuthority),
(transactionContext, builder) -> builder.withValue(Tasks.STATUS, Tasks.STATUS_COMPLETED),
- new ReferringTo<>(Instances.TASK_ID, task))
- ), resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- // the task list contains exactly one task with the title "Updated"
- new Counted<>(1, new BulkAssert<>(new TasksTable(mAuthority))),
- new AssertRelated<>(new TasksTable(mAuthority), Tasks.LIST_ID, taskList,
- new Composite<>(
- new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
- // the instances table contains one instance
- new Counted<>(1, new BulkAssert<>(new InstanceTable(mAuthority))),
- // the instances table contains the given instance
- new Counted<>(1, new BulkAssert<>(
- new InstanceTable(mAuthority),
- new Composite<>(
- new InstanceTestData(-1),
- new CharSequenceRowData<>(Tasks.TITLE, "task1")),
- new ReferringTo<>(Instances.TASK_ID, task)))));
+ new ReferringTo<>(Instances.TASK_ID, task))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ // the task list contains exactly one task with the title "Updated"
+ new Counted<>(1, new BulkAssert<>(new TasksTable(mAuthority))),
+ new AssertRelated<>(new TasksTable(mAuthority), Tasks.LIST_ID, taskList,
+ new Composite<>(new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
+ // the instances table contains one instance
+ new Counted<>(1, new BulkAssert<>(new InstanceTable(mAuthority))),
+ // the instances table contains the given instance
+ new Counted<>(1,
+ new BulkAssert<>(new InstanceTable(mAuthority),
+ new Composite<>(new InstanceTestData(-1),
+ new CharSequenceRowData<>(Tasks.TITLE, "task1")),
+ new ReferringTo<>(Instances.TASK_ID, task)))));
}
-
- /**
- * Create a single instance and delete it.
- */
+ /** Create a single instance and delete it. */
@Test
- public void testDeleteSingleInstance()
- {
+ public void testDeleteSingleInstance() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TasksTable(mAuthority));
@@ -243,24 +211,22 @@ public class TaskProviderInstancesTest
// create a local list
new Put<>(taskList, new NameData("list1")),
// insert a new task
- new Put<>(task, new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
+ new Put<>(task,
+ new Referring<>(Tasks.LIST_ID, taskList, new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
// delete the instance
- new BulkDelete<>(new InstanceTable(mAuthority), new ReferringTo<>(Instances.TASK_ID, task))
- ), resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- // the list does not contain a single task
- new AssertEmptyTable<>(new TasksTable(mAuthority)),
- new AssertEmptyTable<>(new InstanceTable(mAuthority))));
-
+ new BulkDelete<>(new InstanceTable(mAuthority), new ReferringTo<>(Instances.TASK_ID, task))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ // the list does not contain a single task
+ new AssertEmptyTable<>(new TasksTable(mAuthority)),
+ new AssertEmptyTable<>(new InstanceTable(mAuthority))));
}
-
/**
- * Create a single instance and insert an override for exactly the same instance.
+ * Create a single instance and insert an override for exactly the same
+ * instance.
*/
@Test(expected = IllegalArgumentException.class)
- public void testInsertSingleInstanceTwice() throws RemoteException, OperationApplicationException
- {
+ public void testInsertSingleInstanceTwice() throws RemoteException, OperationApplicationException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TasksTable(mAuthority));
RowSnapshot instance = new VirtualRowSnapshot<>(new InstanceTable(mAuthority));
@@ -271,33 +237,29 @@ public class TaskProviderInstancesTest
new BaseTransaction().with(new Seq<>(
// create a local list
new Put<>(taskList, new NameData("list1")),
- // insert a new task into the tasks table (we insert a task to get a RowReference to the new row)
+ // insert a new task into the tasks table (we insert a task to get a
+ // RowReference to
+ // the new row)
new Put<>(task,
- new Composite<>(
- new Referring<>(Tasks.LIST_ID, taskList),
- new TimeData<>(dateTime),
+ new Composite<>(new Referring<>(Tasks.LIST_ID, taskList), new TimeData<>(dateTime),
new TitleData("task1"))),
- new Put<>(instance,
- new Composite<>(
- new Referring<>(Tasks.LIST_ID, taskList),
- new CharSequenceRowData<>(Tasks.DTSTART, "1234"),
- // insert an instance which would override the original instance, which already exists
- new Referring<>(Tasks.ORIGINAL_INSTANCE_ID, task),
- new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_TIME, dtstart),
- new CharSequenceRowData<>(Tasks.TZ, "UTC"),
- new CharSequenceRowData<>(Tasks.TITLE, "task1")))
-
- )).commit(mClient);
+ new Put<>(instance, new Composite<>(new Referring<>(Tasks.LIST_ID, taskList),
+ new CharSequenceRowData<>(Tasks.DTSTART, "1234"),
+ // insert an instance which would override the original instance, which
+ // already exists
+ new Referring<>(Tasks.ORIGINAL_INSTANCE_ID, task),
+ new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_TIME, dtstart),
+ new CharSequenceRowData<>(Tasks.TZ, "UTC"), new CharSequenceRowData<>(Tasks.TITLE, "task1")))))
+ .commit(mClient);
}
-
/**
- * Create a single instance and insert an override for a new instance, turning the event into a recurring event.
+ * Create a single instance and insert an override for a new instance, turning
+ * the event into a recurring event.
*/
@Ignore("Inserting instances is currently not supported.")
@Test
- public void testInsertSingleInstanceAddAnother()
- {
+ public void testInsertSingleInstanceAddAnother() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TasksTable(mAuthority));
RowSnapshot instance = new VirtualRowSnapshot<>(new InstanceTable(mAuthority));
@@ -310,53 +272,52 @@ public class TaskProviderInstancesTest
assertThat(new Seq<>(
// create a local list
new Put<>(taskList, new NameData("list1")),
- // insert a new task into the tasks table (we insert a task to get a RowReference to the new row)
+ // insert a new task into the tasks table (we insert a task to get a
+ // RowReference to the
+ // new row)
new Put<>(task,
- new Composite(
- new Referring<>(Tasks.LIST_ID, taskList),
- new TimeData(dateTimeOriginal),
+ new Composite(new Referring<>(Tasks.LIST_ID, taskList), new TimeData(dateTimeOriginal),
new TitleData("task1"))),
new Put<>(instance,
- new Composite(
- new Referring<>(Tasks.LIST_ID, taskList),
+ new Composite(new Referring<>(Tasks.LIST_ID, taskList),
new CharSequenceRowData<>(Tasks.DTSTART, "1234"),
new CharSequenceRowData<>(Tasks.IS_ALLDAY, "0"),
// insert an override instance
new Referring<>(Tasks.ORIGINAL_INSTANCE_ID, task),
new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_TIME, startOverride),
new CharSequenceRowData<>(Tasks.TZ, "UTC"),
- new CharSequenceRowData<>(Tasks.TITLE, "task override")))
-
- ), resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- // the task list contains exactly two tasks
- new Counted<>(2, new BulkAssert<>(new TasksTable(mAuthority))),
- // check that the original task has RDATES now, one for the original start and one for the new override
- new Assert<>(task,
- new Composite(
- new Referring<>(Tasks.LIST_ID, taskList),
- new TimeData(dateTimeOriginal),
- new CharSequenceRowData<>(Tasks.RDATE, "20180110T224500Z,20180111T224500Z"),
- new TitleData("task1"))),
- // and check there is a task for the override
- new AssertRelated<>(new TasksTable(mAuthority), Tasks.ORIGINAL_INSTANCE_ID, task,
- new Composite(
- new Referring<>(Tasks.LIST_ID, taskList),
- new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_TIME, startOverride),
- new TimeData(new DateTime(1234)),
- new TitleData("task override")))
+ new CharSequenceRowData<>(Tasks.TITLE, "task override")))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ // the task list contains exactly two tasks
+ new Counted<>(2, new BulkAssert<>(new TasksTable(mAuthority))),
+ // check that the original task has RDATES now, one for the original start and
+ // one for
+ // the new override
+ new Assert<>(task,
+ new Composite(new Referring<>(Tasks.LIST_ID, taskList),
+ new TimeData(dateTimeOriginal),
+ new CharSequenceRowData<>(Tasks.RDATE, "20180110T224500Z,20180111T224500Z"),
+ new TitleData("task1"))),
+ // and check there is a task for the override
+ new AssertRelated<>(new TasksTable(mAuthority), Tasks.ORIGINAL_INSTANCE_ID, task,
+ new Composite(new Referring<>(Tasks.LIST_ID, taskList),
+ new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_TIME, startOverride),
+ new TimeData(new DateTime(1234)), new TitleData("task override")))
// TODO: enable tests below once recurrence has been implemented
-// // the instances table contains two instances as well
-// new Counted<>(2, new BulkAssert<>(new InstanceTable(mAuthority))),
-// // one instance is related to the task
-// new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
-// new Composite<>(
-// new InstanceTestData(new Present<>(dateTimeOriginal), new Absent<>(), new Present<>(dateTimeOriginal), 0),
-// new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
-// // the other instance is for the override
-// new Assert<>(instance, new Composite<>(
-// new InstanceTestData(new Present<>(new DateTime(1234)), new Absent<>(), new Present<>(dateTimeOverride), 0),
-// new CharSequenceRowData<>(Tasks.TITLE, "task override")))
- ));
+ // // the instances table contains two instances as well
+ // new Counted<>(2, new BulkAssert<>(new InstanceTable(mAuthority))),
+ // // one instance is related to the task
+ // new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID,
+ // task,
+ // new Composite<>(
+ // new InstanceTestData(new Present<>(dateTimeOriginal),
+ // new Absent<>(), new Present<>(dateTimeOriginal), 0),
+ // new CharSequenceRowData<>(Tasks.TITLE, "task1"))),
+ // // the other instance is for the override
+ // new Assert<>(instance, new Composite<>(
+ // new InstanceTestData(new Present<>(new DateTime(1234)), new
+ // Absent<>(), new Present<>(dateTimeOverride), 0),
+ // new CharSequenceRowData<>(Tasks.TITLE, "task override")))
+ ));
}
}
diff --git a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderObserverTest.java b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderObserverTest.java
index 4784e53f9fdf362bcb1890f525eefe27f4f03d6d..a8c3fe84c9fc7e4f51da0c81453f2fabc5502bdf 100644
--- a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderObserverTest.java
+++ b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderObserverTest.java
@@ -16,13 +16,26 @@
package org.dmfs.provider.tasks;
+import static org.dmfs.android.contentpal.testing.android.uri.UriMatcher.hasParam;
+import static org.dmfs.provider.tasks.matchers.NotifiesMatcher.notifies;
+import static org.dmfs.provider.tasks.matchers.UriMatcher.authority;
+import static org.dmfs.provider.tasks.matchers.UriMatcher.path;
+import static org.dmfs.provider.tasks.matchers.UriMatcher.scheme;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.emptyIterable;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.content.Context;
import android.content.OperationApplicationException;
import android.os.Build;
import android.os.RemoteException;
-
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
import org.dmfs.android.contentpal.Operation;
import org.dmfs.android.contentpal.OperationsQueue;
import org.dmfs.android.contentpal.RowSnapshot;
@@ -48,192 +61,112 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import static org.dmfs.android.contentpal.testing.android.uri.UriMatcher.hasParam;
-import static org.dmfs.provider.tasks.matchers.NotifiesMatcher.notifies;
-import static org.dmfs.provider.tasks.matchers.UriMatcher.authority;
-import static org.dmfs.provider.tasks.matchers.UriMatcher.path;
-import static org.dmfs.provider.tasks.matchers.UriMatcher.scheme;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.emptyIterable;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.startsWith;
-
-
/**
* Tests for {@link TaskProvider}.
*
* @author Marten Gajda
*/
@RunWith(AndroidJUnit4.class)
-public class TaskProviderObserverTest
-{
+public class TaskProviderObserverTest {
private String mAuthority;
private Context mContext;
private ContentProviderClient mClient;
private final Account testAccount = new Account("foo", "bar");
-
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
mContext = InstrumentationRegistry.getTargetContext();
mAuthority = AuthorityUtil.taskAuthority(mContext);
mClient = mContext.getContentResolver().acquireContentProviderClient(mAuthority);
// Assert that tables are empty:
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new AssertEmptyTable<>(new TasksTable(mAuthority)),
+ queue.enqueue(new Seq>(new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new TaskListsTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
queue.flush();
}
-
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
/*
- TODO When Test Orchestration is available, there will be no need for clean up here and check in setUp(), every test method will run in separate instrumentation
- https://android-developers.googleblog.com/2017/07/android-testing-support-library-10-is.html
- https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator
- */
+ * TODO When Test Orchestration is available, there will be no need for clean up
+ * here and check in setUp(), every test method will run in separate
+ * instrumentation
+ * https://android-developers.googleblog.com/2017/07/android-testing-support-
+ * library-10-is.html
+ * https://developer.android.com/training/testing/junit-runner.html#using-
+ * android-test-orchestrator
+ */
// Clear the DB:
BasicOperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new BulkDelete<>(new LocalTaskListsTable(mAuthority)),
+ queue.enqueue(new Seq>(new BulkDelete<>(new LocalTaskListsTable(mAuthority)),
new BulkDelete<>(new Synced<>(testAccount, new TaskListsTable(mAuthority)))));
queue.flush();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mClient.close();
- }
- else
- {
+ } else {
mClient.release();
}
}
-
- /**
- * Test notifications for creating one task list and task.
- */
+ /** Test notifications for creating one task list and task. */
@Test
- public void testSingleInsert() throws RemoteException, OperationApplicationException
- {
+ public void testSingleInsert() throws RemoteException, OperationApplicationException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
OperationsQueue queue = new BasicOperationsQueue(mClient);
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(task, new TitleData("task1"))),
- notifies(
- TaskContract.getContentUri(mAuthority),
- queue,
- containsInAnyOrder(
- allOf(
- scheme("content"),
- authority(mAuthority),
- path(is("/tasks"))
- ),
- allOf(
- scheme("content"),
- authority(mAuthority),
- path(startsWith("/tasks/"))
- ),
- allOf(
- scheme("content"),
- authority(mAuthority),
- path(startsWith("/instances"))
- ),
- allOf(
- scheme("content"),
- authority(mAuthority),
- path(startsWith("/tasklists/"))
- ),
- allOf(
- scheme("content"),
- authority(mAuthority),
- path(is("/tasklists")),
+ assertThat(new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(task, new TitleData("task1"))),
+ notifies(TaskContract.getContentUri(mAuthority), queue,
+ containsInAnyOrder(allOf(scheme("content"), authority(mAuthority), path(is("/tasks"))),
+ allOf(scheme("content"), authority(mAuthority), path(startsWith("/tasks/"))),
+ allOf(scheme("content"), authority(mAuthority), path(startsWith("/instances"))),
+ allOf(scheme("content"), authority(mAuthority), path(startsWith("/tasklists/"))),
+ allOf(scheme("content"), authority(mAuthority), path(is("/tasklists")),
hasParam(TaskContract.CALLER_IS_SYNCADAPTER, "true"),
hasParam(TaskContract.ACCOUNT_NAME, TaskContract.LOCAL_ACCOUNT_NAME),
- hasParam(TaskContract.ACCOUNT_TYPE, TaskContract.LOCAL_ACCOUNT_TYPE)
- ))));
+ hasParam(TaskContract.ACCOUNT_TYPE, TaskContract.LOCAL_ACCOUNT_TYPE)))));
}
-
- /**
- * Update a task and check the notifications.
- */
+ /** Update a task and check the notifications. */
@Test
- public void testSingleUpdate() throws RemoteException, OperationApplicationException
- {
+ public void testSingleUpdate() throws RemoteException, OperationApplicationException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(
- new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(task, new TitleData("task1"))));
+ queue.enqueue(new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(task, new TitleData("task1"))));
queue.flush();
- assertThat(new Seq<>(
- new Put<>(task, new TitleData("task1b"))),
- notifies(
- TaskContract.getContentUri(mAuthority),
- queue,
- // taskprovider should notity the tasks URI iself, the task diretory and the instances directory
- containsInAnyOrder(
- allOf(
- scheme("content"),
- authority(mAuthority),
- path(is("/tasks"))
- ),
- allOf(
- scheme("content"),
- authority(mAuthority),
- path(startsWith("/tasks/"))
- ),
- allOf(
- scheme("content"),
- authority(mAuthority),
- path(is("/instances"))
- ))));
+ assertThat(new Seq<>(new Put<>(task, new TitleData("task1b"))),
+ notifies(TaskContract.getContentUri(mAuthority), queue,
+ // taskprovider should notity the tasks URI iself, the task diretory and the
+ // instances
+ // directory
+ containsInAnyOrder(allOf(scheme("content"), authority(mAuthority), path(is("/tasks"))),
+ allOf(scheme("content"), authority(mAuthority), path(startsWith("/tasks/"))),
+ allOf(scheme("content"), authority(mAuthority), path(is("/instances"))))));
}
-
/**
- * Test that an update that doesn't change anything doesn't trigger a notification.
+ * Test that an update that doesn't change anything doesn't trigger a
+ * notification.
*/
@Test
- public void testNoOpUpdate() throws RemoteException, OperationApplicationException
- {
+ public void testNoOpUpdate() throws RemoteException, OperationApplicationException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(
- new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(task, new TitleData("task1"))));
+ queue.enqueue(new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(task, new TitleData("task1"))));
queue.flush();
- assertThat(new Seq<>(
- new Put<>(task, new TitleData("task1"))),
- notifies(
- TaskContract.getContentUri(mAuthority),
- queue,
+ assertThat(new Seq<>(new Put<>(task, new TitleData("task1"))),
+ notifies(TaskContract.getContentUri(mAuthority), queue,
// there should no notification
emptyIterable()));
}
-
}
diff --git a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderRecurrenceTest.java b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderRecurrenceTest.java
index 727bf5328180576ab03eda58c82fb1a0e2c233e1..b313739a62426d0a0927ee2fcfa9f810eeaaf307 100644
--- a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderRecurrenceTest.java
+++ b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderRecurrenceTest.java
@@ -16,10 +16,16 @@
package org.dmfs.provider.tasks;
+import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
+import static org.dmfs.optional.Absent.absent;
+import static org.junit.Assert.assertThat;
+
import android.content.ContentProviderClient;
import android.content.Context;
import android.os.Build;
-
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+import java.util.TimeZone;
import org.dmfs.android.contentpal.Operation;
import org.dmfs.android.contentpal.OperationsQueue;
import org.dmfs.android.contentpal.RowSnapshot;
@@ -74,77 +80,58 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.TimeZone;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
-import static org.dmfs.optional.Absent.absent;
-import static org.junit.Assert.assertThat;
-
-
/**
* Recurrence Tests for {@link TaskProvider}.
*
* @author Marten Gajda
*/
@RunWith(AndroidJUnit4.class)
-public class TaskProviderRecurrenceTest
-{
+public class TaskProviderRecurrenceTest {
private String mAuthority;
private Context mContext;
private ContentProviderClient mClient;
-
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
mContext = InstrumentationRegistry.getTargetContext();
mAuthority = AuthorityUtil.taskAuthority(mContext);
mClient = mContext.getContentResolver().acquireContentProviderClient(mAuthority);
// Assert that tables are empty:
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new AssertEmptyTable<>(new TasksTable(mAuthority)),
+ queue.enqueue(new Seq>(new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new TaskListsTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
queue.flush();
}
-
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
/*
- TODO When Test Orchestration is available, there will be no need for clean up here and check in setUp(), every test method will run in separate instrumentation
- https://android-developers.googleblog.com/2017/07/android-testing-support-library-10-is.html
- https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator
- */
+ * TODO When Test Orchestration is available, there will be no need for clean up
+ * here and check in setUp(), every test method will run in separate
+ * instrumentation
+ * https://android-developers.googleblog.com/2017/07/android-testing-support-
+ * library-10-is.html
+ * https://developer.android.com/training/testing/junit-runner.html#using-
+ * android-test-orchestrator
+ */
// Clear the DB:
BasicOperationsQueue queue = new BasicOperationsQueue(mClient);
queue.enqueue(new SingletonIterable>(new BulkDelete<>(new LocalTaskListsTable(mAuthority))));
queue.flush();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mClient.close();
- }
- else
- {
+ } else {
mClient.release();
}
}
-
- /**
- * Test if instances of a task with a DTSTART, DUE and an RRULE.
- */
+ /** Test if instances of a task with a DTSTART, DUE and an RRULE. */
@Test
- public void testRRule() throws InvalidRecurrenceRuleException
- {
+ public void testRRule() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -163,52 +150,57 @@ public class TaskProviderRecurrenceTest
DateTime localDue = due.shiftTimeZone(TimeZone.getDefault());
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
-// new Counted<>(5, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp())) */)
- );
+ new Composite<>(new TimeData<>(start, due),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5",
+ RecurrenceRule.RfcMode.RFC2445_LAX))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
+ // new Counted<>(5, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(second,
+ * second.addDuration(hour), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3rd instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(third, third.addDuration(hour), new
+ * Present<>(third), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 4), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
/**
- * Test if instances of a task with a timed DTSTART, DUE and a floating RRULE UNTIL.
+ * Test if instances of a task with a timed DTSTART, DUE and a floating RRULE
+ * UNTIL.
+ *
*
- * Note, this combination should not be accepted by the provider. For the time being, however, it should be tolerated instead of causing a crash.
+ * Note, this combination should not be accepted by the provider. For the time
+ * being, however, it should be tolerated instead of causing a crash.
*/
@Test
- public void testRRuleWithFloatingMismatch() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleWithFloatingMismatch() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -227,50 +219,50 @@ public class TaskProviderRecurrenceTest
DateTime localDue = due.shiftTimeZone(TimeZone.getDefault());
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;UNTIL=20180106", RecurrenceRule.RfcMode.RFC2445_LAX))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;UNTIL=20180106"))),
-// new Counted<>(5, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp())) */)
- );
+ new Composite<>(new TimeData<>(start, due),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;UNTIL=20180106",
+ RecurrenceRule.RfcMode.RFC2445_LAX))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;UNTIL=20180106"))),
+ // new Counted<>(5, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(second,
+ * second.addDuration(hour), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3rd instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(third, third.addDuration(hour), new
+ * Present<>(third), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 4), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
- /**
- * Test if instances of a task with an all-day DTSTART, DUE and an RRULE.
- */
+ /** Test if instances of a task with an all-day DTSTART, DUE and an RRULE. */
@Test
- public void testAllDayRRule() throws InvalidRecurrenceRuleException
- {
+ public void testAllDayRRule() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -289,52 +281,57 @@ public class TaskProviderRecurrenceTest
DateTime localDue = due;
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
-// new Counted<>(5, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp())) */)
- );
+ new Composite<>(new TimeData<>(start, due),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5",
+ RecurrenceRule.RfcMode.RFC2445_LAX))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
+ // new Counted<>(5, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(second,
+ * second.addDuration(hour), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3rd instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(third, third.addDuration(hour), new
+ * Present<>(third), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 4), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
/**
- * Test if instances of a task with an all-day DTSTART, DUE and an RRULE with an absolute UNTIL
+ * Test if instances of a task with an all-day DTSTART, DUE and an RRULE with an
+ * absolute UNTIL
+ *
*
- * Note, this combination should not be accepted by the provider. For the time being, however, it should be tolerated instead of causing a crash.
+ * Note, this combination should not be accepted by the provider. For the time
+ * being, however, it should be tolerated instead of causing a crash.
*/
@Test
- public void testAllDayRRuleFloatingMismatch() throws InvalidRecurrenceRuleException
- {
+ public void testAllDayRRuleFloatingMismatch() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -353,50 +350,50 @@ public class TaskProviderRecurrenceTest
DateTime localDue = due;
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;UNTIL=20180106T120000Z", RecurrenceRule.RfcMode.RFC2445_LAX))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;UNTIL=20180106T120000Z"))),
-// new Counted<>(5, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp())) */)
- );
+ new Composite<>(new TimeData<>(start, due),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;UNTIL=20180106T120000Z",
+ RecurrenceRule.RfcMode.RFC2445_LAX))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;UNTIL=20180106T120000Z"))),
+ // new Counted<>(5, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(second,
+ * second.addDuration(hour), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3rd instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(third, third.addDuration(hour), new
+ * Present<>(third), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 4), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
- /**
- * Test if instances of a task with a DUE and an RRULE but no DTSTART.
- */
+ /** Test if instances of a task with a DUE and an RRULE but no DTSTART. */
@Test
- public void testRRuleNoDtStart() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleNoDtStart() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -412,50 +409,50 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new DueData<>(due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new DueData<>(due),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
-// new Counted<>(5, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(absent(), new Present<>(localDue), new Present<>(due), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, due.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(absent(), new Present<>(second), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(absent(), new Present<>(third), new Present<>(third), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(absent(), new Present<>(fourth), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(absent(), new Present<>(fifth), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))*/)
- );
+ new Composite<>(new DueData<>(due),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5",
+ RecurrenceRule.RfcMode.RFC2445_LAX))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new DueData<>(due),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
+ // new Counted<>(5, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(absent(), new Present<>(localDue), new Present<>(due), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, due
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(absent(),
+ * new Present<>(second), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3rd instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(absent(), new Present<>(third), new
+ * Present<>(third), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(absent(), new Present<>(fourth), new
+ * Present<>(fourth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(absent(), new Present<>(fifth), new
+ * Present<>(fifth), 4), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
- /**
- * Test if instances of a task with a DTSTART and an RRULE but no DUE
- */
+ /** Test if instances of a task with a DTSTART and an RRULE but no DUE */
@Test
- public void testRRuleNoDue() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleNoDue() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -471,51 +468,51 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new TimeData<>(start),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
-// new Counted<>(5, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(new Present<>(localStart), absent(), new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(new Present<>(second), absent(), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(new Present<>(third), absent(), new Present<>(third), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(new Present<>(fourth), absent(), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(new Present<>(fifth), absent(), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))*/)
- );
+ new Composite<>(new TimeData<>(start),
+ new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5",
+ RecurrenceRule.RfcMode.RFC2445_LAX))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
+ // new Counted<>(5, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(new Present<>(localStart), absent(), new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(new
+ * Present<>(second), absent(), new Present<>(second), 1),
+ * new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3rd instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(new Present<>(third), absent(), new
+ * Present<>(third), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(new Present<>(fourth), absent(), new
+ * Present<>(fourth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(new Present<>(fifth), absent(), new
+ * Present<>(fifth), 4), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
- /**
- * Remove an instance from a task with an RRULE.
- */
+ /** Remove an instance from a task with an RRULE. */
@Ignore("Test tries to delete 3rd instance which has not been created because currently only 1 instance is expanded")
@Test
- public void testRRuleRemoveInstance() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleRemoveInstance() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -534,53 +531,46 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ new Put<>(task, new Composite<>(new TimeData<>(start, due),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
// remove the third instance
new BulkDelete<>(instancesTable,
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task), new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
+ new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())))),
+ resultsIn(mClient, new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"),
new CharSequenceRowData<>(Tasks.EXDATE, "20180106T123456Z"))),
- new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())),
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 4th instance (now 3rd):
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance (now 4th):
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp())))
- );
+ new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())),
+ // 2nd instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
+ // 4th instance (now 3rd):
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 2),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
+ // 5th instance (now 4th):
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 3),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))));
}
-
- /**
- * Test RRULE with overridden instance (inserted into the tasks table)
- */
+ /** Test RRULE with overridden instance (inserted into the tasks table) */
@Test
- public void testRRuleWithOverride() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleWithOverride() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskOverride = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskOverride = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
Duration hour = new Duration(1, 0, 3600 /* 1 hour */);
DateTime start = DateTime.parse("20180104T123456Z");
@@ -596,68 +586,73 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new TitleData("original"),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ new Put<>(task, new Composite<>(new TimeData<>(start, due), new TitleData("original"),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
// the override moves the instance by an hour
- new Put<>(taskOverride, new Composite<>(
- new TimeData<>(third.addDuration(hour), third.addDuration(hour).addDuration(hour)),
- new TitleData("override"),
- new OriginalInstanceData(task, third)))
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.TITLE, "original"),
+ new Put<>(taskOverride,
+ new Composite<>(
+ new TimeData<>(third.addDuration(hour),
+ third.addDuration(hour).addDuration(hour)),
+ new TitleData("override"), new OriginalInstanceData(task, third)))),
+ resultsIn(mClient, new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due), new CharSequenceRowData<>(Tasks.TITLE, "original"),
new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
- new Assert<>(taskOverride,
- new Composite<>(
- new TimeData<>(third.addDuration(hour), third.addDuration(hour).addDuration(hour)),
- new CharSequenceRowData<>(Tasks.TITLE, "override"),
- new OriginalInstanceData(task, third))),
-// new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, taskOverride)),
- new Counted<>(0, new AssertRelated<>(instancesTable, Instances.TASK_ID, taskOverride)),
-// new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3th instance (the overridden one):
- new AssertRelated<>(instancesTable, Instances.TASK_ID, taskOverride,
- new InstanceTestData(third.addDuration(hour), third.addDuration(hour).addDuration(hour), new Present<>(third),
- 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))*/)
- );
+ new Assert<>(taskOverride,
+ new Composite<>(
+ new TimeData<>(third.addDuration(hour), third.addDuration(hour)
+ .addDuration(hour)),
+ new CharSequenceRowData<>(Tasks.TITLE, "override"),
+ new OriginalInstanceData(task, third))),
+ // new Counted<>(1, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, taskOverride)),
+ new Counted<>(0, new AssertRelated<>(instancesTable, Instances.TASK_ID, taskOverride)),
+ // new Counted<>(4, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(second,
+ * second.addDuration(hour), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3th instance (the overridden
+ * one): new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, taskOverride, new
+ * InstanceTestData(third.addDuration(hour),
+ * third.addDuration(hour).addDuration(hour), new
+ * Present<>(third), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 4), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
/**
- * Test RRULE with overridden instance (inserted into the tasks table) and a completed 1st instance.
+ * Test RRULE with overridden instance (inserted into the tasks table) and a
+ * completed 1st instance.
*/
@Test
- public void testRRuleWith2ndOverrideAndCompleted1st() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleWith2ndOverrideAndCompleted1st() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskOverride = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskOverride = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
Duration hour = new Duration(1, 0, 3600 /* 1 hour */);
DateTime start = DateTime.parse("20180104T123456Z");
@@ -673,54 +668,52 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new TitleData("original"),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ new Put<>(task, new Composite<>(new TimeData<>(start, due), new TitleData("original"),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
// the override moves the instance by an hour
- new Put<>(taskOverride, new Composite<>(
- new TimeData<>(second.addDuration(hour), second.addDuration(hour).addDuration(hour)),
- new TitleData("override"),
- new OriginalInstanceData(task, second))),
- new Put<>(task, new StatusData<>(Tasks.STATUS_COMPLETED))),
- resultsIn(mClient,
- new Assert<>(task,
+ new Put<>(taskOverride,
new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.TITLE, "original"),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"),
- new StatusData<>(Tasks.STATUS_COMPLETED))),
+ new TimeData<>(second.addDuration(hour),
+ second.addDuration(hour).addDuration(hour)),
+ new TitleData("override"), new OriginalInstanceData(task, second))),
+ new Put<>(task, new StatusData<>(Tasks.STATUS_COMPLETED))),
+ resultsIn(mClient, new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due), new CharSequenceRowData<>(Tasks.TITLE, "original"),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"),
+ new StatusData<>(Tasks.STATUS_COMPLETED))),
new Assert<>(taskOverride,
new Composite<>(
- new TimeData<>(second.addDuration(hour), second.addDuration(hour).addDuration(hour)),
+ new TimeData<>(second.addDuration(hour),
+ second.addDuration(hour).addDuration(hour)),
new CharSequenceRowData<>(Tasks.TITLE, "override"),
new OriginalInstanceData(task, second))),
// 1st (completed) instance:
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), -1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))),
+ new Counted<>(1,
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), -1),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))),
// 2nd instance (now the current one):
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, taskOverride,
- new InstanceTestData(
- second.addDuration(hour),
- second.addDuration(hour).addDuration(hour),
- new Present<>(second), 0)))));
+ new Counted<>(1,
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, taskOverride,
+ new InstanceTestData(second.addDuration(hour),
+ second.addDuration(hour).addDuration(hour), new Present<>(second),
+ 0)))));
}
-
/**
- * Test RRULE with overridden instance (inserted into the tasks table) and a deleted 1st instance.
+ * Test RRULE with overridden instance (inserted into the tasks table) and a
+ * deleted 1st instance.
*/
@Test
- public void testRRuleWith2ndOverrideAndDeleted1st() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleWith2ndOverrideAndDeleted1st() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskOverride = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskOverride = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
Duration hour = new Duration(1, 0, 3600 /* 1 hour */);
DateTime start = DateTime.parse("20180104T123456Z");
@@ -736,54 +729,51 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new TitleData("original"),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ new Put<>(task, new Composite<>(new TimeData<>(start, due), new TitleData("original"),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
// the override moves the instance by an hour
- new Put<>(taskOverride, new Composite<>(
- new TimeData<>(second.addDuration(hour), second.addDuration(hour).addDuration(hour)),
- new TitleData("override"),
- new OriginalInstanceData(task, second))),
- // delete 1st instance
- new BulkDelete<>(instancesTable, new AllOf<>(
- new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.DISTANCE_FROM_CURRENT, "0")))),
- resultsIn(mClient,
- new Assert<>(task,
+ new Put<>(taskOverride,
new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.TITLE, "original"),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"),
- new CharSequenceRowData<>(Tasks.EXDATE, start.toString()),
- new StatusData<>(Tasks.STATUS_DEFAULT))),
+ new TimeData<>(second.addDuration(hour),
+ second.addDuration(hour).addDuration(hour)),
+ new TitleData("override"), new OriginalInstanceData(task, second))),
+ // delete 1st instance
+ new BulkDelete<>(instancesTable,
+ new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
+ new EqArg<>(Instances.DISTANCE_FROM_CURRENT, "0")))),
+ resultsIn(mClient, new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due), new CharSequenceRowData<>(Tasks.TITLE, "original"),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"),
+ new CharSequenceRowData<>(Tasks.EXDATE, start.toString()),
+ new StatusData<>(Tasks.STATUS_DEFAULT))),
new Assert<>(taskOverride,
new Composite<>(
- new TimeData<>(second.addDuration(hour), second.addDuration(hour).addDuration(hour)),
+ new TimeData<>(second.addDuration(hour),
+ second.addDuration(hour).addDuration(hour)),
new CharSequenceRowData<>(Tasks.TITLE, "override"),
new OriginalInstanceData(task, second))),
// no instances point to the original task
new Counted<>(0, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
// 2nd instance (now the current one):
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, taskOverride,
- new InstanceTestData(
- second.addDuration(hour),
- second.addDuration(hour).addDuration(hour),
- new Present<>(second), 0)))));
+ new Counted<>(1,
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, taskOverride,
+ new InstanceTestData(second.addDuration(hour),
+ second.addDuration(hour).addDuration(hour), new Present<>(second),
+ 0)))));
}
-
/**
- * Test RRULE with overridden instance (via update on the instances table). This time we don't override the date time fields and expect the instance to
- * inherit the original instance start and due (instead of the master start and due)
+ * Test RRULE with overridden instance (via update on the instances table). This
+ * time we don't override the date time fields and expect the instance to
+ * inherit the original instance start and due (instead of the master start and
+ * due)
*/
@Ignore("Test tries to override the 3rd instance which has not been created because we currently only expand one instance.")
@Test
- public void testRRuleWithOverride2() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleWithOverride2() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table tasksTable = new TasksTable(mAuthority);
Table instancesTable = new InstanceTable(mAuthority);
@@ -803,62 +793,56 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new TitleData("original"),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ new Put<>(task, new Composite<>(new TimeData<>(start, due), new TitleData("original"),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)))),
// the override just changes the title
new BulkUpdate<>(instancesTable,
- new Composite<>(
- new CharSequenceRowData(Tasks.TITLE, "override")),
- new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task), new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())))
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.TITLE, "original"),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
- new AssertRelated<>(tasksTable, Tasks.ORIGINAL_INSTANCE_ID, task,
- new Composite<>(
+ new Composite<>(new CharSequenceRowData(Tasks.TITLE, "override")),
+ new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.TITLE, "original"), new CharSequenceRowData<>(
+ Tasks.RRULE, "FREQ=DAILY;COUNT=5"))),
+ new AssertRelated<>(tasksTable, Tasks.ORIGINAL_INSTANCE_ID, task, new Composite<>(
// note the task table contains the original time zone, not the default one
- new TimeData<>(third.shiftTimeZone(start.getTimeZone()), third.shiftTimeZone(start.getTimeZone()).addDuration(hour)),
+ new TimeData<>(third.shiftTimeZone(start.getTimeZone()),
+ third.shiftTimeZone(start.getTimeZone()).addDuration(hour)),
new CharSequenceRowData<>(Tasks.TITLE, "override"),
new OriginalInstanceData(task, third))),
- new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.ORIGINAL_INSTANCE_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())),
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3th instance (the overridden one). We don't have a row reference to this row, so we select it by the ORIGINAL_INSTANCE-ID
- new AssertRelated<>(instancesTable, Tasks.ORIGINAL_INSTANCE_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp())))
- );
+ new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.ORIGINAL_INSTANCE_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())),
+ // 2nd instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
+ // 3th instance (the overridden one). We don't have a row reference to this row,
+ // so we
+ // select it by the ORIGINAL_INSTANCE-ID
+ new AssertRelated<>(instancesTable, Tasks.ORIGINAL_INSTANCE_ID, task,
+ new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 2),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
+ // 4th instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 3),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
+ // 5th instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 4),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))));
}
-
- /**
- * Test if instances of a task with a DTSTART, an RRULE and EXDATEs.
- */
+ /** Test if instances of a task with a DTSTART, an RRULE and EXDATEs. */
@Test
- public void testRRuleWithExDates() throws InvalidRecurrenceRuleException
- {
+ public void testRRuleWithExDates() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -877,44 +861,41 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)),
- new ExDatesTaskData(new Seq<>(third, fifth))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"),
- new CharSequenceRowData<>(Tasks.EXDATE, "20180106T123456Z,20180108T123456Z"))),
-// new Counted<>(3, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 4th instance (now 3rd):
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp()))*/)
- );
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ new Put<>(task, new Composite<>(new TimeData<>(start, due),
+ new RRuleTaskData(
+ new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX)),
+ new ExDatesTaskData(new Seq<>(third, fifth))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.RRULE, "FREQ=DAILY;COUNT=5"),
+ new CharSequenceRowData<>(Tasks.EXDATE, "20180106T123456Z,20180108T123456Z"))),
+ // new Counted<>(3, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(second,
+ * second.addDuration(hour), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 4th instance (now 3rd): new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp()))
+ */));
}
-
- /**
- * Test if instances of a task with a DTSTART and RDATEs.
- */
+ /** Test if instances of a task with a DTSTART and RDATEs. */
@Test
- public void testRDate() throws InvalidRecurrenceRuleException
- {
+ public void testRDate() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -933,56 +914,53 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RDatesTaskData(new Seq<>(start, second, third, fourth, fifth))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.RDATE,
- "20180104T123456Z," +
- "20180105T123456Z," +
- "20180106T123456Z," +
- "20180107T123456Z," +
- "20180108T123456Z"
- ))),
-// new Counted<>(5, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 4),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))*/)
- );
+ new Composite<>(new TimeData<>(start, due),
+ new RDatesTaskData(new Seq<>(start, second, third, fourth, fifth))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.RDATE,
+ "20180104T123456Z," + "20180105T123456Z," + "20180106T123456Z,"
+ + "20180107T123456Z," + "20180108T123456Z"))),
+ // new Counted<>(5, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(second,
+ * second.addDuration(hour), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3rd instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(third, third.addDuration(hour), new
+ * Present<>(third), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 4), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
/**
* Test if instances of a task with a DTSTART and RDATEs, add exdate afterwards.
*/
@Test
- public void testRDateAddExDate() throws InvalidRecurrenceRuleException
- {
+ public void testRDateAddExDate() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
@@ -1001,65 +979,59 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
+ new Composite<>(new TimeData<>(start, due),
new RDatesTaskData(new Seq<>(start, second, third, fourth, fifth)))),
// the third instance becomed an exdate now
- new Put<>(task,
- new Composite<>(
- new ExDatesTaskData(new Seq<>(third))))
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.RDATE,
- "20180104T123456Z," +
- "20180105T123456Z," +
- "20180106T123456Z," +
- "20180107T123456Z," +
- "20180108T123456Z"),
- new CharSequenceRowData<>(Tasks.EXDATE,
- "20180106T123456Z"
- ))),
-// new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(localStart, localDue, new Present<>(start), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp()))/*,
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())),
- // 3rd instance:
-// new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
-// new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 2),
-// new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))*/)
- );
+ new Put<>(task, new Composite<>(new ExDatesTaskData(new Seq<>(third))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.RDATE,
+ "20180104T123456Z," + "20180105T123456Z," + "20180106T123456Z,"
+ + "20180107T123456Z," + "20180108T123456Z"),
+ new CharSequenceRowData<>(Tasks.EXDATE, "20180106T123456Z"))),
+ // new Counted<>(4, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(localStart, localDue, new Present<>(start), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start
+ .getTimestamp())) /*
+ * , // 2nd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(second,
+ * second.addDuration(hour), new Present<>(second), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * second.getTimestamp())), // 3rd instance: // new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * // new InstanceTestData(third, third.addDuration(hour),
+ * new Present<>(third), 2), // new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
- /**
- * Test if instances of a task with a DTSTART and RDATEs, complete first.
- */
+ /** Test if instances of a task with a DTSTART and RDATEs, complete first. */
@Test
- public void testRDateFirstComplete() throws InvalidRecurrenceRuleException
- {
+ public void testRDateFirstComplete() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot override = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot override = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
Duration hour = new Duration(1, 0, 3600 /* 1 hour */);
DateTime start = DateTime.parse("20180104T123456Z");
@@ -1075,68 +1047,63 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- // first insert new task,
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RDatesTaskData(new Seq<>(start, second, third, fourth, fifth)))),
- // next, insert override
- new Put<>(override,
- new Composite<>(
- new TimeData<>(start, due),
- new OriginalInstanceData(task, start),
- new StatusData<>(Tasks.STATUS_COMPLETED)))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new CharSequenceRowData<>(Tasks.RDATE,
- "20180104T123456Z," +
- "20180105T123456Z," +
- "20180106T123456Z," +
- "20180107T123456Z," +
- "20180108T123456Z"
- ))),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, override)),
-// new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, override,
- new InstanceTestData(localStart, localDue, new Present<>(start), -1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())),
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp()))/*,
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))*/)
- );
+ assertThat(new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ // first insert new task,
+ new Put<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new RDatesTaskData(new Seq<>(start, second, third, fourth, fifth)))),
+ // next, insert override
+ new Put<>(override,
+ new Composite<>(new TimeData<>(start, due), new OriginalInstanceData(task, start),
+ new StatusData<>(Tasks.STATUS_COMPLETED)))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new CharSequenceRowData<>(Tasks.RDATE,
+ "20180104T123456Z," + "20180105T123456Z," + "20180106T123456Z,"
+ + "20180107T123456Z," + "20180108T123456Z"))),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, override)),
+ // new Counted<>(4, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, override,
+ new InstanceTestData(localStart, localDue, new Present<>(start), -1),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())),
+ // 2nd instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second
+ .getTimestamp())) /*
+ * , // 3rd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(third,
+ * third.addDuration(hour), new Present<>(third), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
/**
- * Test if instances of a task with a DTSTART and RDATEs, complete first inserted first.
+ * Test if instances of a task with a DTSTART and RDATEs, complete first
+ * inserted first.
*/
@Test
- public void testRDateFirstCompleteFirstInserted() throws InvalidRecurrenceRuleException
- {
+ public void testRDateFirstCompleteFirstInserted() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table instancesTable = new InstanceTable(mAuthority);
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot override = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot override = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
Duration hour = new Duration(1, 0, 3600 /* 1 hour */);
DateTime start = DateTime.parse("20180104T123456Z");
@@ -1152,71 +1119,62 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- // first insert override
- new Put<>(override,
- new Composite<>(
- new TimeData<>(start, due),
+ assertThat(new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ // first insert override
+ new Put<>(override,
+ new Composite<>(new TimeData<>(start, due), new OriginalInstanceSyncIdData("xyz", start),
+ new StatusData<>(Tasks.STATUS_COMPLETED))),
+ // then insert task
+ new Put<>(task,
+ new Composite<>(new SyncIdData("xyz"), new TimeData<>(start, due),
+ new RDatesTaskData(new Seq<>(start, second, third, fourth, fifth))))),
+ resultsIn(mClient,
+ new Assert<>(task,
+ new Composite<>(new TimeData<>(start, due), new SyncIdData("xyz"),
+ new CharSequenceRowData<>(Tasks.RDATE,
+ "20180104T123456Z," + "20180105T123456Z," + "20180106T123456Z,"
+ + "20180107T123456Z," + "20180108T123456Z"))),
+ new Assert<>(override,
+ new Composite<>(new TimeData<>(start, due),
new OriginalInstanceSyncIdData("xyz", start),
new StatusData<>(Tasks.STATUS_COMPLETED))),
- // then insert task
- new Put<>(task,
- new Composite<>(
- new SyncIdData("xyz"),
- new TimeData<>(start, due),
- new RDatesTaskData(new Seq<>(start, second, third, fourth, fifth))))
-
- ), resultsIn(mClient,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new SyncIdData("xyz"),
- new CharSequenceRowData<>(Tasks.RDATE,
- "20180104T123456Z," +
- "20180105T123456Z," +
- "20180106T123456Z," +
- "20180107T123456Z," +
- "20180108T123456Z"
- ))),
- new Assert<>(override,
- new Composite<>(
- new TimeData<>(start, due),
- new OriginalInstanceSyncIdData("xyz", start),
- new StatusData<>(Tasks.STATUS_COMPLETED))),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, override)),
-// new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
- // 1st instance, overridden and completed
- new AssertRelated<>(instancesTable, Instances.TASK_ID, override,
- new InstanceTestData(localStart, localDue, new Present<>(start), -1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())),
- // 2nd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp()))/*,
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))*/)
- );
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, override)),
+ // new Counted<>(4, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // 1st instance, overridden and completed
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, override,
+ new InstanceTestData(localStart, localDue, new Present<>(start), -1),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())),
+ // 2nd instance:
+ new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second
+ .getTimestamp())) /*
+ * , // 3rd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(third,
+ * third.addDuration(hour), new Present<>(third), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
/**
- * Test if instances of a task with a DTSTART and RDATEs, complete first via instances table.
+ * Test if instances of a task with a DTSTART and RDATEs, complete first via
+ * instances table.
*/
@Test
- public void testRDateFirstCompleteViaInstances() throws InvalidRecurrenceRuleException
- {
+ public void testRDateFirstCompleteViaInstances() throws InvalidRecurrenceRuleException {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
Table tasksTable = new TasksTable(mAuthority);
Table instancesTable = new InstanceTable(mAuthority);
@@ -1236,70 +1194,71 @@ public class TaskProviderRecurrenceTest
DateTime fourth = third.addDuration(day);
DateTime fifth = fourth.addDuration(day);
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData<>()),
- // first insert the task
- new Put<>(task,
- new Composite<>(
- new TimeData<>(start, due),
- new RDatesTaskData(start, second, third, fourth, fifth))),
- // then complete the first instance
- new BulkUpdate<>(instancesTable, new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED)),
- new AllOf<>(
- new ReferringTo<>(Instances.TASK_ID, task),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())))),
+ assertThat(new Seq<>(new Put<>(taskList, new EmptyRowData<>()),
+ // first insert the task
+ new Put<>(task,
+ new Composite<>(new TimeData<>(start, due),
+ new RDatesTaskData(start, second, third, fourth, fifth))),
+ // then complete the first instance
+ new BulkUpdate<>(instancesTable,
+ new CharSequenceRowData<>(Tasks.STATUS, String.valueOf(Tasks.STATUS_COMPLETED)),
+ new AllOf<>(new ReferringTo<>(Instances.TASK_ID, task),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, start.getTimestamp())))),
resultsIn(mClient,
- // we've already closed the first instance which has been detached, the master now points to the second instance
- new Counted<>(1,
- new Assert<>(task,
- new Composite<>(
- new TimeData<>(DateTime.parse("20180105T123456Z"), DateTime.parse("20180105T133456Z")),
- new RDatesTaskData(
- // "20180104T123456Z" // the detached instance
- DateTime.parse("20180105T123456Z"),
- DateTime.parse("20180106T123456Z"),
- DateTime.parse("20180107T123456Z"),
- DateTime.parse("20180108T123456Z"))))),
- // there must be one task which is not equal to the original task, it's the detached instance
- new Counted<>(1,
- new BulkAssert<>(tasksTable,
- new Composite<>(
- new TimeData<>(start, due),
- new StatusData<>(Tasks.STATUS_COMPLETED),
- new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_ID, null),
- new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_SYNC_ID, null),
- new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_TIME, null)),
- new Not<>(new ReferringTo<>(Tasks._ID, task)))),
+ // we've already closed the first instance which has been detached, the master
+ // now
+ // points to the second instance
+ new Counted<>(1, new Assert<>(task, new Composite<>(
+ new TimeData<>(DateTime.parse("20180105T123456Z"), DateTime.parse("20180105T133456Z")),
+ new RDatesTaskData(
+ // "20180104T123456Z" // the detached instance
+ DateTime.parse("20180105T123456Z"), DateTime.parse("20180106T123456Z"),
+ DateTime.parse("20180107T123456Z"), DateTime.parse("20180108T123456Z"))))),
+ // there must be one task which is not equal to the original task, it's the
+ // detached
+ // instance
+ new Counted<>(1, new BulkAssert<>(tasksTable,
+ new Composite<>(new TimeData<>(start, due), new StatusData<>(Tasks.STATUS_COMPLETED),
+ new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_ID, null),
+ new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_SYNC_ID, null),
+ new CharSequenceRowData<>(Tasks.ORIGINAL_INSTANCE_TIME, null)),
+ new Not<>(new ReferringTo<>(Tasks._ID, task)))),
// and one instance which doesn't refer to the original task
- new Counted<>(1, new BulkAssert<>(instancesTable, new Not<>(new ReferringTo<>(Instances.TASK_ID, task)))),
+ new Counted<>(1,
+ new BulkAssert<>(instancesTable,
+ new Not<>(new ReferringTo<>(Instances.TASK_ID, task)))),
// but 4 instances of that original task
-// new Counted<>(4, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
+ // new Counted<>(4, new AssertRelated<>(instancesTable,
+ // Instances.TASK_ID, task)),
new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task)),
// 1st instance, detached and completed
- new Counted<>(1, new BulkAssert<>(instancesTable,
- new Composite<>(
- new InstanceTestData(localStart, localDue, absent(), -1)),
- new AllOf<>(
- new IsNull<>(Instances.INSTANCE_ORIGINAL_TIME), // the detached instance has no INSTANCE_ORIGINAL_TIME
- new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
- // 2nd instance:
new Counted<>(1,
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 0),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second.getTimestamp())))/*,
- // 3rd instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(third, third.addDuration(hour), new Present<>(third), 1),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, third.getTimestamp())),
- // 4th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fourth, fourth.addDuration(hour), new Present<>(fourth), 2),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fourth.getTimestamp())),
- // 5th instance:
- new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
- new InstanceTestData(fifth, fifth.addDuration(hour), new Present<>(fifth), 3),
- new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, fifth.getTimestamp()))*/)
- );
+ new BulkAssert<>(instancesTable,
+ new Composite<>(new InstanceTestData(localStart, localDue, absent(), -1)),
+ new AllOf<>(new IsNull<>(Instances.INSTANCE_ORIGINAL_TIME), // the detached
+ // instance has no
+ // INSTANCE_ORIGINAL_TIME
+ new Not<>(new ReferringTo<>(Instances.TASK_ID, task))))),
+ // 2nd instance:
+ new Counted<>(1, new AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ new InstanceTestData(second, second.addDuration(hour), new Present<>(second), 0),
+ new EqArg<>(Instances.INSTANCE_ORIGINAL_TIME, second
+ .getTimestamp()))) /*
+ * , // 3rd instance: new AssertRelated<>(instancesTable,
+ * Instances.TASK_ID, task, new InstanceTestData(third,
+ * third.addDuration(hour), new Present<>(third), 1), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * third.getTimestamp())), // 4th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fourth, fourth.addDuration(hour),
+ * new Present<>(fourth), 2), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fourth.getTimestamp())), // 5th instance: new
+ * AssertRelated<>(instancesTable, Instances.TASK_ID, task,
+ * new InstanceTestData(fifth, fifth.addDuration(hour), new
+ * Present<>(fifth), 3), new
+ * EqArg<>(Instances.INSTANCE_ORIGINAL_TIME,
+ * fifth.getTimestamp()))
+ */));
}
-
}
diff --git a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderRelatingTest.java b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderRelatingTest.java
index f7595805fb478535e9e98848768913de87032f42..14e62e6c896202cf695ef8053910f3da7e09fab0 100644
--- a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderRelatingTest.java
+++ b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderRelatingTest.java
@@ -16,12 +16,16 @@
package org.dmfs.provider.tasks;
+import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
+import static org.junit.Assert.assertThat;
+
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
import android.os.Build;
-
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
import org.dmfs.android.contentpal.Operation;
import org.dmfs.android.contentpal.OperationsQueue;
import org.dmfs.android.contentpal.RowSnapshot;
@@ -58,31 +62,21 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
-import static org.junit.Assert.assertThat;
-
-
/**
* Tests for {@link TaskProvider} reparenting feature.
*
* @author Marten Gajda
*/
@RunWith(AndroidJUnit4.class)
-public class TaskProviderRelatingTest
-{
+public class TaskProviderRelatingTest {
private ContentResolver mResolver;
private String mAuthority;
private Context mContext;
private ContentProviderClient mClient;
private final Account testAccount = new Account("foo", "bar");
-
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
mContext = InstrumentationRegistry.getTargetContext();
mResolver = mContext.getContentResolver();
mAuthority = AuthorityUtil.taskAuthority(mContext);
@@ -90,95 +84,88 @@ public class TaskProviderRelatingTest
// Assert that tables are empty:
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new AssertEmptyTable<>(new TasksTable(mAuthority)),
+ queue.enqueue(new Seq>(new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new TaskListsTable(mAuthority)),
new AssertEmptyTable<>(new PropertiesTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
queue.flush();
}
-
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
/*
- TODO When Test Orchestration is available, there will be no need for clean up here and check in setUp(), every test method will run in separate instrumentation
- https://android-developers.googleblog.com/2017/07/android-testing-support-library-10-is.html
- https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator
- */
+ * TODO When Test Orchestration is available, there will be no need for clean up
+ * here and check in setUp(), every test method will run in separate
+ * instrumentation
+ * https://android-developers.googleblog.com/2017/07/android-testing-support-
+ * library-10-is.html
+ * https://developer.android.com/training/testing/junit-runner.html#using-
+ * android-test-orchestrator
+ */
// Clear the DB:
BasicOperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new BulkDelete<>(new LocalTaskListsTable(mAuthority)),
+ queue.enqueue(new Seq>(new BulkDelete<>(new LocalTaskListsTable(mAuthority)),
new BulkDelete<>(new PropertiesTable(mAuthority)),
new BulkDelete<>(new Synced<>(testAccount, new TaskListsTable(mAuthority)))));
queue.flush();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mClient.close();
- }
- else
- {
+ } else {
mClient.release();
}
}
-
/**
- * Create 1 local task list, then create a child Task, related to a parent UID and finally the parent.
+ * Create 1 local task list, then create a child Task, related to a parent UID
+ * and finally the parent.
*/
@Test
- public void testRelateTask()
- {
- RowSnapshot taskList = new VirtualRowSnapshot<>(new Synced<>(testAccount, new TaskListsTable(mAuthority)));
- RowSnapshot taskChild = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new Synced<>(testAccount, new TasksTable(mAuthority))));
- RowSnapshot taskParent = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new Synced<>(testAccount, new TasksTable(mAuthority))));
-
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(taskChild, new Composite<>(
- new TitleData("child"),
- new CharSequenceRowData<>(Tasks._UID, "childUID"))),
+ public void testRelateTask() {
+ RowSnapshot taskList = new VirtualRowSnapshot<>(
+ new Synced<>(testAccount, new TaskListsTable(mAuthority)));
+ RowSnapshot taskChild = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new Synced<>(testAccount, new TasksTable(mAuthority))));
+ RowSnapshot taskParent = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new Synced<>(testAccount, new TasksTable(mAuthority))));
+
+ assertThat(
+ new Seq<>(new Put<>(taskList, new NameData("list1")),
+ new Put<>(
+ taskChild,
+ new Composite<>(new TitleData("child"),
+ new CharSequenceRowData<>(Tasks._UID, "childUID"))),
new Insert<>(new PropertiesTable(mAuthority), new Composite<>(
- new CharSequenceRowData<>(TaskContract.Property.Relation.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new CharSequenceRowData<>(TaskContract.Property.Relation.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
new Referring<>(TaskContract.Property.Relation.TASK_ID, taskChild),
new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_UID, "parentUID"),
- new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE, String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT))
- )),
- new Put<>(taskParent, new Composite<>(
- new TitleData("parent"),
- new CharSequenceRowData<>(Tasks._UID, "parentUID")))
- ),
- resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- new Assert<>(taskChild, new Composite<>(
- new TitleData("child"),
- new CharSequenceRowData<>(Tasks._UID, "childUID"),
+ new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
+ String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)))),
+ new Put<>(taskParent,
+ new Composite<>(new TitleData("parent"),
+ new CharSequenceRowData<>(Tasks._UID, "parentUID")))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")), new Assert<>(taskChild,
+ new Composite<>(new TitleData("child"), new CharSequenceRowData<>(Tasks._UID, "childUID"),
new Referring<>(Tasks.PARENT_ID, taskParent))),
- new Assert<>(taskParent, new Composite<>(
- new CharSequenceRowData<>(Tasks._UID, "parentUID"),
- new TitleData("parent"))),
- new Counted<>(1, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new Composite<>(
- new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
- String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)),
- new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_UID, "parentUID"),
- new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskParent)
- ),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)
- ))),
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
+ new Assert<>(taskParent,
+ new Composite<>(new CharSequenceRowData<>(Tasks._UID, "parentUID"),
+ new TitleData("parent"))),
+ new Counted<>(1, new BulkAssert<>(new PropertiesTable(mAuthority), new Composite<>(
+ new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
+ String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)),
+ new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_UID, "parentUID"),
+ new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskParent)),
new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent)
- )))
- ));
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent))))));
}
}
diff --git a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderReparentingTest.java b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderReparentingTest.java
index 57eedc1fda205bf5bc9dfe8d6d22362726f29d40..0c8fb6ca3d4883399548058c4168840472d4f22b 100644
--- a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderReparentingTest.java
+++ b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderReparentingTest.java
@@ -16,12 +16,16 @@
package org.dmfs.provider.tasks;
+import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
+import static org.junit.Assert.assertThat;
+
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
import android.os.Build;
-
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
import org.dmfs.android.contentpal.Operation;
import org.dmfs.android.contentpal.OperationsQueue;
import org.dmfs.android.contentpal.RowSnapshot;
@@ -58,31 +62,21 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
-import static org.junit.Assert.assertThat;
-
-
/**
* Tests for {@link TaskProvider} reparenting feature.
*
* @author Marten Gajda
*/
@RunWith(AndroidJUnit4.class)
-public class TaskProviderReparentingTest
-{
+public class TaskProviderReparentingTest {
private ContentResolver mResolver;
private String mAuthority;
private Context mContext;
private ContentProviderClient mClient;
private final Account testAccount = new Account("foo", "bar");
-
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
mContext = InstrumentationRegistry.getTargetContext();
mResolver = mContext.getContentResolver();
mAuthority = AuthorityUtil.taskAuthority(mContext);
@@ -90,303 +84,263 @@ public class TaskProviderReparentingTest
// Assert that tables are empty:
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new AssertEmptyTable<>(new TasksTable(mAuthority)),
+ queue.enqueue(new Seq>(new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new TaskListsTable(mAuthority)),
new AssertEmptyTable<>(new PropertiesTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
queue.flush();
}
-
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
/*
- TODO When Test Orchestration is available, there will be no need for clean up here and check in setUp(), every test method will run in separate instrumentation
- https://android-developers.googleblog.com/2017/07/android-testing-support-library-10-is.html
- https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator
- */
+ * TODO When Test Orchestration is available, there will be no need for clean up
+ * here and check in setUp(), every test method will run in separate
+ * instrumentation
+ * https://android-developers.googleblog.com/2017/07/android-testing-support-
+ * library-10-is.html
+ * https://developer.android.com/training/testing/junit-runner.html#using-
+ * android-test-orchestrator
+ */
// Clear the DB:
BasicOperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new BulkDelete<>(new LocalTaskListsTable(mAuthority)),
+ queue.enqueue(new Seq>(new BulkDelete<>(new LocalTaskListsTable(mAuthority)),
new BulkDelete<>(new PropertiesTable(mAuthority)),
new BulkDelete<>(new Synced<>(testAccount, new TaskListsTable(mAuthority)))));
queue.flush();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mClient.close();
- }
- else
- {
+ } else {
mClient.release();
}
}
-
- /**
- * Create 1 local task list and a parent and a child task.
- */
+ /** Create 1 local task list and a parent and a child task. */
@Test
- public void testRelateTask()
- {
+ public void testRelateTask() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
- RowSnapshot taskChild = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskParent = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
-
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(taskParent, new TitleData("parent")),
- new Put<>(taskChild, new Composite<>(
- new TitleData("child"),
- new Referring<>(Tasks.PARENT_ID, taskParent)))
- ),
- resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- new Assert<>(taskChild, new Composite<>(
- new TitleData("child"),
- new Referring<>(Tasks.PARENT_ID, taskParent))),
- new Assert<>(taskParent, new Composite<>(
- new TitleData("parent"))),
- new Counted<>(1, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new Composite<>(
- new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
- String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)),
- new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskParent)
- ),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)
- ))),
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent)
- )))
- ));
+ RowSnapshot taskChild = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskParent = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+
+ assertThat(
+ new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(taskParent, new TitleData("parent")),
+ new Put<>(taskChild,
+ new Composite<>(new TitleData("child"), new Referring<>(Tasks.PARENT_ID, taskParent)))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ new Assert<>(taskChild,
+ new Composite<>(new TitleData("child"), new Referring<>(Tasks.PARENT_ID, taskParent))),
+ new Assert<>(taskParent, new Composite<>(new TitleData("parent"))),
+ new Counted<>(1,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new Composite<>(
+ new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
+ String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)),
+ new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskParent)),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent))))));
}
-
/**
- * Create 1 local task list and 2 tasks, in a second operation make the second one parent of the first one.
+ * Create 1 local task list and 2 tasks, in a second operation make the second
+ * one parent of the first one.
*/
@Test
- public void testAdoptTask()
- {
+ public void testAdoptTask() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
- RowSnapshot taskChild = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskParent = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskChild = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskParent = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(taskChild, new TitleData("child")),
+ assertThat(
+ new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(taskChild, new TitleData("child")),
new Put<>(taskParent, new TitleData("parent")),
- new Put<>(taskChild, new Referring<>(Tasks.PARENT_ID, taskParent))
- ),
- resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- new Assert<>(taskChild, new Composite<>(
- new TitleData("child"),
- new Referring<>(Tasks.PARENT_ID, taskParent))),
- new Assert<>(taskParent, new Composite<>(
- new TitleData("parent"))),
- new Counted<>(1, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new Composite<>(
- new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
- String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)),
- new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskParent)
- ),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)
- ))),
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent)
- )))
- ));
+ new Put<>(taskChild, new Referring<>(Tasks.PARENT_ID, taskParent))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ new Assert<>(taskChild,
+ new Composite<>(new TitleData("child"), new Referring<>(Tasks.PARENT_ID, taskParent))),
+ new Assert<>(taskParent, new Composite<>(new TitleData("parent"))),
+ new Counted<>(1,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new Composite<>(
+ new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
+ String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)),
+ new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskParent)),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent))))));
}
-
/**
- * Create 1 local task list and 3 tasks, create parent child relationship and change it afterwards
+ * Create 1 local task list and 3 tasks, create parent child relationship and
+ * change it afterwards
*/
@Test
- public void testReparentTask()
- {
+ public void testReparentTask() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
- RowSnapshot taskChild = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskParent = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskNewParent = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
-
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(taskParent, new TitleData("parent")),
- new Put<>(taskChild, new Composite<>(
- new TitleData("child"),
- new Referring<>(Tasks.PARENT_ID, taskParent))),
+ RowSnapshot taskChild = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskParent = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskNewParent = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+
+ assertThat(
+ new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(taskParent, new TitleData("parent")),
+ new Put<>(taskChild,
+ new Composite<>(new TitleData("child"), new Referring<>(Tasks.PARENT_ID, taskParent))),
new Put<>(taskNewParent, new TitleData("newParent")),
- new Put<>(taskChild, new Referring<>(Tasks.PARENT_ID, taskNewParent))
- ),
- resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- new Assert<>(taskChild, new Composite<>(
- new TitleData("child"),
- new Referring<>(Tasks.PARENT_ID, taskNewParent))),
- new Assert<>(taskParent, new Composite<>(
- new TitleData("parent"))),
- new Assert<>(taskNewParent, new Composite<>(
- new TitleData("newParent"))),
-
- new Counted<>(1, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new Composite<>(
+ new Put<>(taskChild, new Referring<>(Tasks.PARENT_ID, taskNewParent))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ new Assert<>(taskChild,
+ new Composite<>(new TitleData("child"),
+ new Referring<>(Tasks.PARENT_ID, taskNewParent))),
+ new Assert<>(taskParent, new Composite<>(new TitleData("parent"))),
+ new Assert<>(taskNewParent, new Composite<>(new TitleData("newParent"))),
+ new Counted<>(1,
+ new BulkAssert<>(new PropertiesTable(mAuthority), new Composite<>(
new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)),
- new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskNewParent)
- ),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)
- ))),
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent)
- ))),
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskNewParent)
- )))
- ));
+ new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskNewParent)),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority), new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent)))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskNewParent))))));
}
-
/**
- * Create 1 local task list and 4 tasks, create parent child relationship with a sibling and change it afterwards
+ * Create 1 local task list and 4 tasks, create parent child relationship with a
+ * sibling and change it afterwards
*/
@Test
- public void testReparentTaskWithSibling()
- {
+ public void testReparentTaskWithSibling() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
- RowSnapshot taskChild = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskParent = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskNewParent = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskSibling = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
-
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(taskParent, new TitleData("parent")),
- new Put<>(taskChild, new Composite<>(
- new TitleData("child"),
- new Referring<>(Tasks.PARENT_ID, taskParent))),
+ RowSnapshot taskChild = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskParent = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskNewParent = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskSibling = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+
+ assertThat(
+ new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(taskParent, new TitleData("parent")),
+ new Put<>(taskChild,
+ new Composite<>(new TitleData("child"), new Referring<>(Tasks.PARENT_ID, taskParent))),
new Put<>(taskNewParent, new TitleData("newParent")),
new Put<>(taskSibling, new TitleData("sibling")),
- new Insert<>(new PropertiesTable(mAuthority), new Composite<>(
- new CharSequenceRowData<>(TaskContract.Property.Relation.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new Referring<>(TaskContract.Property.Relation.TASK_ID, taskSibling),
- new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskChild),
- new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE, String.valueOf(
- TaskContract.Property.Relation.RELTYPE_SIBLING))
- )),
- new Put<>(taskChild, new Referring<>(Tasks.PARENT_ID, taskNewParent))
- ),
- resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- new Assert<>(taskChild, new Composite<>(
- new TitleData("child"),
- new Referring<>(Tasks.PARENT_ID, taskNewParent))),
- new Assert<>(taskParent, new Composite<>(
- new TitleData("parent"))),
- new Assert<>(taskNewParent, new Composite<>(
- new TitleData("newParent"))),
- new Assert<>(taskSibling, new Composite<>(
- new TitleData("sibling"))),
-
- new Counted<>(1, new BulkAssert<>(
- new PropertiesTable(mAuthority),
+ new Insert<>(new PropertiesTable(mAuthority),
new Composite<>(
+ new CharSequenceRowData<>(TaskContract.Property.Relation.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new Referring<>(TaskContract.Property.Relation.TASK_ID, taskSibling),
+ new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskChild),
+ new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
+ String.valueOf(TaskContract.Property.Relation.RELTYPE_SIBLING)))),
+ new Put<>(taskChild, new Referring<>(Tasks.PARENT_ID, taskNewParent))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ new Assert<>(taskChild,
+ new Composite<>(new TitleData("child"),
+ new Referring<>(Tasks.PARENT_ID, taskNewParent))),
+ new Assert<>(taskParent, new Composite<>(new TitleData("parent"))),
+ new Assert<>(taskNewParent, new Composite<>(new TitleData("newParent"))),
+ new Assert<>(taskSibling, new Composite<>(new TitleData("sibling"))),
+ new Counted<>(1,
+ new BulkAssert<>(new PropertiesTable(mAuthority), new Composite<>(
new CharSequenceRowData<>(TaskContract.Property.Relation.RELATED_TYPE,
String.valueOf(TaskContract.Property.Relation.RELTYPE_PARENT)),
- new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskNewParent)
- ),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)
- ))),
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent)
- ))),
- // yikes the sibling became an orphan because it has no relation to its parent anymore.
+ new Referring<>(TaskContract.Property.Relation.RELATED_ID, taskNewParent)),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent)))),
+ // yikes the sibling became an orphan because it has no relation to its parent
+ // anymore.
// this should be fixed, see https://github.com/dmfs/opentasks/issues/932
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskSibling)
- ))),
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskNewParent)
- )))
- ));
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskSibling)))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskNewParent))))));
}
-
/**
- * Create 1 local task list and 2 tasks, create parent child relationship and remove it
+ * Create 1 local task list and 2 tasks, create parent child relationship and
+ * remove it
*/
@Test
- public void testOrphanTask()
- {
+ public void testOrphanTask() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
- RowSnapshot taskChild = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- RowSnapshot taskParent = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
-
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(taskParent, new TitleData("parent")),
- new Put<>(taskChild, new Composite<>(
- new TitleData("child"),
- new Referring<>(Tasks.PARENT_ID, taskParent))),
- new Put<>(taskChild, new CharSequenceRowData<>(Tasks.PARENT_ID, null))
- ),
- resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- new Assert<>(taskChild, new Composite<>(
- new TitleData("child"),
- new CharSequenceRowData<>(Tasks.PARENT_ID, null))),
- new Assert<>(taskParent, new Composite<>(
- new TitleData("parent"))),
-
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)
- ))),
- new Counted<>(0, new BulkAssert<>(
- new PropertiesTable(mAuthority),
- new AllOf<>(
- new EqArg<>(TaskContract.Properties.MIMETYPE, TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
- new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent)
- )))
- ));
+ RowSnapshot taskChild = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+ RowSnapshot taskParent = new VirtualRowSnapshot<>(
+ new TaskListScoped(taskList, new TasksTable(mAuthority)));
+
+ assertThat(
+ new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(taskParent, new TitleData("parent")),
+ new Put<>(taskChild,
+ new Composite<>(new TitleData("child"), new Referring<>(Tasks.PARENT_ID, taskParent))),
+ new Put<>(taskChild, new CharSequenceRowData<>(Tasks.PARENT_ID, null))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ new Assert<>(taskChild,
+ new Composite<>(new TitleData("child"),
+ new CharSequenceRowData<>(Tasks.PARENT_ID, null))),
+ new Assert<>(taskParent, new Composite<>(new TitleData("parent"))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskChild)))),
+ new Counted<>(0,
+ new BulkAssert<>(new PropertiesTable(mAuthority),
+ new AllOf<>(
+ new EqArg<>(TaskContract.Properties.MIMETYPE,
+ TaskContract.Property.Relation.CONTENT_ITEM_TYPE),
+ new ReferringTo<>(TaskContract.Properties.TASK_ID, taskParent))))));
}
}
diff --git a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderTest.java b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderTest.java
index 47a8d9d3e8a44a97c10d6ae763a171e3d8d5fc70..4adea98b520d195879409bb7bde157779e6bfe3f 100644
--- a/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderTest.java
+++ b/opentasks-provider/src/androidTest/java/org/dmfs/provider/tasks/TaskProviderTest.java
@@ -16,13 +16,19 @@
package org.dmfs.provider.tasks;
+import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
+import static org.dmfs.optional.Absent.absent;
+import static org.junit.Assert.assertThat;
+
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.os.Build;
-
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+import java.util.TimeZone;
import org.dmfs.android.contentpal.Operation;
import org.dmfs.android.contentpal.OperationsQueue;
import org.dmfs.android.contentpal.RowSnapshot;
@@ -72,16 +78,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.TimeZone;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import static org.dmfs.android.contenttestpal.ContentMatcher.resultsIn;
-import static org.dmfs.optional.Absent.absent;
-import static org.junit.Assert.assertThat;
-
-
/**
* Tests for {@link TaskProvider}.
*
@@ -90,18 +86,15 @@ import static org.junit.Assert.assertThat;
* @author Marten Gajda
*/
@RunWith(AndroidJUnit4.class)
-public class TaskProviderTest
-{
+public class TaskProviderTest {
private ContentResolver mResolver;
private String mAuthority;
private Context mContext;
private ContentProviderClient mClient;
private final Account testAccount = new Account("foo", "bar");
-
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
mContext = InstrumentationRegistry.getTargetContext();
mResolver = mContext.getContentResolver();
mAuthority = AuthorityUtil.taskAuthority(mContext);
@@ -109,101 +102,78 @@ public class TaskProviderTest
// Assert that tables are empty:
OperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new AssertEmptyTable<>(new TasksTable(mAuthority)),
+ queue.enqueue(new Seq>(new AssertEmptyTable<>(new TasksTable(mAuthority)),
new AssertEmptyTable<>(new TaskListsTable(mAuthority)),
new AssertEmptyTable<>(new InstanceTable(mAuthority))));
queue.flush();
}
-
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
/*
- TODO When Test Orchestration is available, there will be no need for clean up here and check in setUp(), every test method will run in separate instrumentation
- https://android-developers.googleblog.com/2017/07/android-testing-support-library-10-is.html
- https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator
- */
+ * TODO When Test Orchestration is available, there will be no need for clean up
+ * here and check in setUp(), every test method will run in separate
+ * instrumentation
+ * https://android-developers.googleblog.com/2017/07/android-testing-support-
+ * library-10-is.html
+ * https://developer.android.com/training/testing/junit-runner.html#using-
+ * android-test-orchestrator
+ */
// Clear the DB:
BasicOperationsQueue queue = new BasicOperationsQueue(mClient);
- queue.enqueue(new Seq>(
- new BulkDelete<>(new LocalTaskListsTable(mAuthority)),
+ queue.enqueue(new Seq>(new BulkDelete<>(new LocalTaskListsTable(mAuthority)),
new BulkDelete<>(new Synced<>(testAccount, new TaskListsTable(mAuthority)))));
queue.flush();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mClient.close();
- }
- else
- {
+ } else {
mClient.release();
}
}
-
/**
- * Create 1 local task list and 1 task, check values in TaskLists, Tasks, Instances tables.
+ * Create 1 local task list and 1 task, check values in TaskLists, Tasks,
+ * Instances tables.
*/
@Test
- public void testSingleInsert()
- {
+ public void testSingleInsert() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(task, new TitleData("task1"))
-
- ), resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- new Assert<>(task, new Composite<>(
- new TitleData("task1"),
- new VersionData(0))),
- new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
- new Composite(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TZ, null))
- )));
+ assertThat(new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(task, new TitleData("task1"))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ new Assert<>(task, new Composite<>(new TitleData("task1"), new VersionData(0))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
+ new Composite(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TZ, null)))));
}
-
/**
- * Create 1 local task list and 1 task, update task via instances table and check values in TaskLists, Tasks, Instances tables.
+ * Create 1 local task list and 1 task, update task via instances table and
+ * check values in TaskLists, Tasks, Instances tables.
*/
@Test
- public void testSingleInsertUpdateInstance()
- {
+ public void testSingleInsertUpdateInstance() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
Table instancesTable = new InstanceTable(mAuthority);
- assertThat(new Seq<>(
- new Put<>(taskList, new NameData("list1")),
- new Put<>(task, new TitleData("task1")),
- new BulkUpdate<>(instancesTable, new CharSequenceRowData<>(Tasks.TITLE, "task updated"), new ReferringTo<>(Instances.TASK_ID, task))
-
- ), resultsIn(mClient,
- new Assert<>(taskList, new NameData("list1")),
- new Assert<>(task, new Composite<>(
- new TitleData("task updated"),
- new VersionData(1))),
- new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
- new Composite(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TZ, null))
- )));
+ assertThat(
+ new Seq<>(new Put<>(taskList, new NameData("list1")), new Put<>(task, new TitleData("task1")),
+ new BulkUpdate<>(instancesTable, new CharSequenceRowData<>(Tasks.TITLE, "task updated"),
+ new ReferringTo<>(Instances.TASK_ID, task))),
+ resultsIn(mClient, new Assert<>(taskList, new NameData("list1")),
+ new Assert<>(task, new Composite<>(new TitleData("task updated"), new VersionData(1))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
+ new Composite(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TZ, null)))));
}
-
- /**
- * Create 2 task list and 3 tasks, check values.
- */
+ /** Create 2 task list and 3 tasks, check values. */
@Test
- public void testMultipleInserts()
- {
+ public void testMultipleInserts() {
Table taskListsTable = new LocalTaskListsTable(mAuthority);
RowSnapshot taskList1 = new VirtualRowSnapshot<>(taskListsTable);
RowSnapshot taskList2 = new VirtualRowSnapshot<>(taskListsTable);
@@ -211,50 +181,29 @@ public class TaskProviderTest
RowSnapshot task2 = new VirtualRowSnapshot<>(new TaskListScoped(taskList1, new TasksTable(mAuthority)));
RowSnapshot task3 = new VirtualRowSnapshot<>(new TaskListScoped(taskList2, new TasksTable(mAuthority)));
- assertThat(new Seq<>(
- new Put<>(taskList1, new NameData("list1")),
- new Put<>(taskList2, new NameData("list2")),
- new Put<>(task1, new TitleData("task1")),
- new Put<>(task2, new TitleData("task2")),
- new Put<>(task3, new TitleData("task3"))
-
- ), resultsIn(mClient,
- new Assert<>(taskList1, new NameData("list1")),
- new Assert<>(taskList2, new NameData("list2")),
- new Assert<>(task1, new Composite<>(
- new TitleData("task1"),
- new VersionData(0))),
- new Assert<>(task2, new Composite<>(
- new TitleData("task2"),
- new VersionData(0))),
- new Assert<>(task3, new Composite<>(
- new TitleData("task3"),
- new VersionData(0))),
- new AssertRelated<>(
- new InstanceTable(mAuthority), Instances.TASK_ID, task1,
- new Composite(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TZ, null))),
- new AssertRelated<>(
- new InstanceTable(mAuthority), Instances.TASK_ID, task2,
- new Composite(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TZ, null))),
- new AssertRelated<>(
- new InstanceTable(mAuthority), Instances.TASK_ID, task3,
- new Composite(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TZ, null))
- )));
+ assertThat(
+ new Seq<>(new Put<>(taskList1, new NameData("list1")), new Put<>(taskList2, new NameData("list2")),
+ new Put<>(task1, new TitleData("task1")), new Put<>(task2, new TitleData("task2")),
+ new Put<>(task3, new TitleData("task3"))),
+ resultsIn(mClient, new Assert<>(taskList1, new NameData("list1")),
+ new Assert<>(taskList2, new NameData("list2")),
+ new Assert<>(task1, new Composite<>(new TitleData("task1"), new VersionData(0))),
+ new Assert<>(task2, new Composite<>(new TitleData("task2"), new VersionData(0))),
+ new Assert<>(task3, new Composite<>(new TitleData("task3"), new VersionData(0))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task1,
+ new Composite(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TZ, null))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task2,
+ new Composite(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TZ, null))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task3,
+ new Composite(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TZ, null)))));
}
-
- /**
- * Create 2 task list and 3 tasks with updates, check values.
- */
+ /** Create 2 task list and 3 tasks with updates, check values. */
@Test
- public void testMultipleInsertsAndUpdates()
- {
+ public void testMultipleInsertsAndUpdates() {
Table taskListsTable = new LocalTaskListsTable(mAuthority);
RowSnapshot taskList1 = new VirtualRowSnapshot<>(taskListsTable);
RowSnapshot taskList2 = new VirtualRowSnapshot<>(taskListsTable);
@@ -262,193 +211,135 @@ public class TaskProviderTest
RowSnapshot task2 = new VirtualRowSnapshot<>(new TaskListScoped(taskList1, new TasksTable(mAuthority)));
RowSnapshot task3 = new VirtualRowSnapshot<>(new TaskListScoped(taskList2, new TasksTable(mAuthority)));
- assertThat(new Seq<>(
- new Put<>(taskList1, new NameData("list1")),
- new Put<>(taskList2, new NameData("list2")),
- new Put<>(task1, new TitleData("task1a")),
- new Put<>(task2, new TitleData("task2a")),
- new Put<>(task3, new TitleData("task3a")),
- // update task 1 and 2
- new Put<>(task1, new TitleData("task1b")),
- new Put<>(task2, new TitleData("task2b")),
- // update task 1 once more
- new Put<>(task1, new TitleData("task1c"))
-
- ), resultsIn(mClient,
- new Assert<>(taskList1, new NameData("list1")),
- new Assert<>(taskList2, new NameData("list2")),
- new Assert<>(task1, new Composite<>(
- new TitleData("task1c"),
- new VersionData(2))),
- new Assert<>(task2, new Composite<>(
- new TitleData("task2b"),
- new VersionData(1))),
- new Assert<>(task3, new Composite<>(
- new TitleData("task3a"),
- new VersionData(0))),
- new AssertRelated<>(
- new InstanceTable(mAuthority), Instances.TASK_ID, task1,
- new Composite(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TZ, null))),
- new AssertRelated<>(
- new InstanceTable(mAuthority), Instances.TASK_ID, task2,
- new Composite(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TZ, null))),
- new AssertRelated<>(
- new InstanceTable(mAuthority), Instances.TASK_ID, task3,
- new Composite(
- new InstanceTestData(0),
- new CharSequenceRowData<>(Tasks.TZ, null))
- )));
+ assertThat(
+ new Seq<>(new Put<>(taskList1, new NameData("list1")), new Put<>(taskList2, new NameData("list2")),
+ new Put<>(task1, new TitleData("task1a")), new Put<>(task2, new TitleData("task2a")),
+ new Put<>(task3, new TitleData("task3a")),
+ // update task 1 and 2
+ new Put<>(task1, new TitleData("task1b")), new Put<>(task2, new TitleData("task2b")),
+ // update task 1 once more
+ new Put<>(task1, new TitleData("task1c"))),
+ resultsIn(mClient, new Assert<>(taskList1, new NameData("list1")),
+ new Assert<>(taskList2, new NameData("list2")),
+ new Assert<>(task1, new Composite<>(new TitleData("task1c"), new VersionData(2))),
+ new Assert<>(task2, new Composite<>(new TitleData("task2b"), new VersionData(1))),
+ new Assert<>(task3, new Composite<>(new TitleData("task3a"), new VersionData(0))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task1,
+ new Composite(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TZ, null))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task2,
+ new Composite(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TZ, null))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task3,
+ new Composite(new InstanceTestData(0),
+ new CharSequenceRowData<>(Tasks.TZ, null)))));
}
-
/**
- * Create task with start and due, check datetime values including generated duration.
+ * Create task with start and due, check datetime values including generated
+ * duration.
*/
@Test
- public void testInsertTaskWithStartAndDue()
- {
+ public void testInsertTaskWithStartAndDue() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
DateTime start = DateTime.now();
DateTime due = start.addDuration(new Duration(1, 1, 0));
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData()),
- new Put<>(task, new TimeData<>(start, due))
-
- ), resultsIn(mClient,
- new Assert<>(task, new Composite<>(
- new TimeData<>(start, due),
- new VersionData(0))),
- new AssertRelated<>(
- new InstanceTable(mAuthority), Instances.TASK_ID, task,
- new Composite(
- new InstanceTestData(
- start.shiftTimeZone(TimeZone.getDefault()),
- due.shiftTimeZone(TimeZone.getDefault()),
- absent(),
- 0),
- new CharSequenceRowData<>(Tasks.TZ, "UTC"))
- )));
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData()),
+ new Put<>(task, new TimeData<>(start, due))),
+ resultsIn(mClient, new Assert<>(task, new Composite<>(new TimeData<>(start, due), new VersionData(0))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
+ new Composite(
+ new InstanceTestData(start.shiftTimeZone(TimeZone.getDefault()),
+ due.shiftTimeZone(TimeZone.getDefault()), absent(), 0),
+ new CharSequenceRowData<>(Tasks.TZ, "UTC")))));
}
-
-
/**
- * Create task with start and due, check datetime values including generated duration.
+ * Create task with start and due, check datetime values including generated
+ * duration.
*/
@Test
- public void testInsertTaskWithAlldayStartAndDue()
- {
+ public void testInsertTaskWithAlldayStartAndDue() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
DateTime start = DateTime.now().toAllDay();
DateTime due = start.addDuration(new Duration(1, 2, 0));
- assertThat(new Seq<>(
- new Put<>(taskList, new EmptyRowData()),
- new Put<>(task, new TimeData<>(start, due))
-
- ), resultsIn(mClient,
- new Assert<>(task, new Composite<>(
- new TimeData<>(start, due),
- new VersionData(0))),
- new AssertRelated<>(
- new InstanceTable(mAuthority), Instances.TASK_ID, task,
- new Composite(
- new InstanceTestData(
- start,
- due,
- absent(),
- 0),
- new CharSequenceRowData<>(Tasks.TZ, "UTC"))
- )));
+ assertThat(
+ new Seq<>(new Put<>(taskList, new EmptyRowData()),
+ new Put<>(task, new TimeData<>(start, due))),
+ resultsIn(mClient, new Assert<>(task, new Composite<>(new TimeData<>(start, due), new VersionData(0))),
+ new AssertRelated<>(new InstanceTable(mAuthority), Instances.TASK_ID, task,
+ new Composite(new InstanceTestData(start, due, absent(), 0),
+ new CharSequenceRowData<>(Tasks.TZ, "UTC")))));
}
-
/**
- * Create task with start and due, check datetime and INSTANCE_STATUS values after updating the status.
+ * Create task with start and due, check datetime and INSTANCE_STATUS values
+ * after updating the status.
*/
@Test
- public void testInsertTaskWithStartAndDueUpdateStatus()
- {
+ public void testInsertTaskWithStartAndDueUpdateStatus() {
RowSnapshot taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot