Skip to content

Commit 7ac6209

Browse files
fixing a parsing issue with the TaskParser where completed state wasn't parsed.
Added test to verify fix. git-svn-id: http://android-shuffle.googlecode.com/svn/trunk@228 c433d9f2-e643-0410-a449-b9b772e888ec
1 parent 4ef8a89 commit 7ac6209

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

TracksTesting/src/org/dodgybits/android/shuffle/test/TaskParserTests.java

+32
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,36 @@ public void testTaskParserBasicParsingTest() {
7070

7171
}
7272

73+
public void testCompletedTasksAreCompletedWhenParsed() {
74+
XmlPullParser xmlParser = Xml.newPullParser();
75+
76+
try {
77+
xmlParser.setInput(new StringReader("<todo>"+
78+
"<completed-at type=\"datetime\" nil=\"true\"/>"+
79+
"<context-id type=\"integer\">3711</context-id>"+
80+
"<created-at type=\"datetime\">2009-10-26T22:23:42+01:00</created-at>"+
81+
"<description>Läs getting things done igen</description>"+
82+
"<due type=\"datetime\" nil=\"true\"/>"+
83+
"<id type=\"integer\">25076</id>"+
84+
"<ip-address>90.232.35.15</ip-address>"+
85+
"<notes>Primärt kring idéer och projekt</notes>"+
86+
"<project-id type=\"integer\">4558</project-id>"+
87+
"<recurring-todo-id type=\"integer\" nil=\"true\"/>"+
88+
"<show-from type=\"datetime\" nil=\"true\"/>"+
89+
"<state>completed</state>"+
90+
"<updated-at type=\"datetime\">2010-02-03T10:37:19+01:00</updated-at>"+
91+
"</todo>"));
92+
} catch (XmlPullParserException e) {
93+
// TODO Auto-generated catch block
94+
e.printStackTrace();
95+
}
96+
TaskParser parser = CreateSUT();
97+
Task task = parser.parseSingle(xmlParser).getResult();
98+
assertEquals("completed date isn't parsed correctly",true,task.isComplete());
99+
100+
101+
102+
}
103+
104+
73105
}

client/src/org/dodgybits/shuffle/android/synchronisation/tracks/parsing/TaskParser.java

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ public TaskParser(IContextLookup contextLookup, IProjectLookup projectLookup, An
2424
mContextLookup = contextLookup;
2525
mProjectLookup = projectLookup;
2626

27+
appliers.put("state", new Applier() {
28+
@Override
29+
public boolean apply(String value) {
30+
if( value.equals("completed"))
31+
specificBuilder.setComplete(true);
32+
return true;
33+
}
34+
});
2735

2836
appliers.put("description",
2937
new Applier(){

0 commit comments

Comments
 (0)