mirror of https://github.com/tasks/tasks
Remove RemoteModelHelpers
parent
5e0d3dc129
commit
7510ee77a0
@ -1,53 +0,0 @@
|
|||||||
package org.tasks;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ContentValues;
|
|
||||||
|
|
||||||
import com.todoroo.andlib.data.Property;
|
|
||||||
import com.todoroo.andlib.data.Table;
|
|
||||||
import com.todoroo.astrid.data.Task;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
|
||||||
import static junit.framework.Assert.fail;
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
public class RemoteModelHelpers {
|
|
||||||
public static Property[] asQueryProperties(Table table, ContentValues contentValues) {
|
|
||||||
Set<String> keys = contentValues.keySet();
|
|
||||||
Property[] result = new Property[keys.size()];
|
|
||||||
int index = 0;
|
|
||||||
for (String key : keys) {
|
|
||||||
result[index++] = new Property.StringProperty(table, key);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void compareRemoteModel(Task expected, Task actual) {
|
|
||||||
compareContentValues(expected.getSetValues(), actual.getSetValues());
|
|
||||||
compareContentValues(expected.getDatabaseValues(), actual.getDatabaseValues());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void compareContentValues(ContentValues expected, ContentValues actual) {
|
|
||||||
if (expected == null && actual == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (expected == null || actual == null) {
|
|
||||||
fail();
|
|
||||||
}
|
|
||||||
for (String key : expected.keySet()) {
|
|
||||||
Object entry = expected.get(key);
|
|
||||||
if (entry instanceof Integer) {
|
|
||||||
assertEquals(entry, actual.getAsInteger(key));
|
|
||||||
} else if (entry instanceof String) {
|
|
||||||
assertEquals(entry, actual.getAsString(key));
|
|
||||||
} else if (entry instanceof Long) {
|
|
||||||
assertEquals(entry, actual.getAsLong(key));
|
|
||||||
} else {
|
|
||||||
fail("Unhandled property type: " + entry.getClass());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue