diff options
| author | Marco Jacob <mjacob@union06.de> | 2013-06-27 11:08:14 -0700 |
|---|---|---|
| committer | Marco Jacob <mjacob@union06.de> | 2013-06-27 11:08:14 -0700 |
| commit | 27fbd56949e1dbb4471c147069f74620e7f54b4d (patch) | |
| tree | 6248b5c4637dba93e1c211ad5bfec08a736233d8 /tests | |
| parent | dc53fa7be33f3052e39952112679c7b0e0b3b324 (diff) | |
| parent | fbc75936daaa3ea5e2596c0aa71593cbe9f33614 (diff) | |
| download | cgeo-27fbd56949e1dbb4471c147069f74620e7f54b4d.zip cgeo-27fbd56949e1dbb4471c147069f74620e7f54b4d.tar.gz cgeo-27fbd56949e1dbb4471c147069f74620e7f54b4d.tar.bz2 | |
Merge pull request #2893 from marco-jacob/fixPersonalNoteFinal
make personalNote multiline, upload on OK and merge on refresh
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/src/cgeo/geocaching/PersonalNoteTest.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/PersonalNoteTest.java b/tests/src/cgeo/geocaching/PersonalNoteTest.java new file mode 100644 index 0000000..fd185ed --- /dev/null +++ b/tests/src/cgeo/geocaching/PersonalNoteTest.java @@ -0,0 +1,68 @@ +package cgeo.geocaching; + +import junit.framework.TestCase; + +public class PersonalNoteTest extends TestCase { + + public static void testParse() { + final String testString = "merged:\nSimple cgeo note\n--\nSimple provider note"; + Geocache cache = new Geocache(); + cache.setPersonalNote(testString); + PersonalNote parsedNote = new PersonalNote(cache); + assertEquals(testString, parsedNote.toString()); + assertPersonalNote(parsedNote, "Simple cgeo note", "Simple provider note"); + + } + + public static void testParseProviderOnly() { + final String testString = "Simple provider note"; + Geocache cache = new Geocache(); + cache.setPersonalNote(testString); + PersonalNote parsedNote = new PersonalNote(cache); + assertEquals(testString, parsedNote.toString()); + assertPersonalNote(parsedNote, null, "Simple provider note"); + } + + public static void testParseCgeoOnly() { + final String testString = "merged:\nSimple cgeo note"; + Geocache cache = new Geocache(); + cache.setPersonalNote(testString); + PersonalNote parsedNote = new PersonalNote(cache); + assertEquals("Simple cgeo note", parsedNote.toString()); + assertPersonalNote(parsedNote, null, "Simple cgeo note"); + } + + public static void testSimpleMerge() { + Geocache cache1 = new Geocache(); // not stored + cache1.setPersonalNote("merged:\nSimple cgeo note\n--\nSimple provider note"); + PersonalNote myNote = new PersonalNote(cache1); + Geocache cache2 = new Geocache(); + cache2.setListId(StoredList.STANDARD_LIST_ID); // stored + cache2.setPersonalNote("merged:\ncgeo note\n--\nProvider note"); + PersonalNote otherNote = new PersonalNote(cache2); + PersonalNote result = myNote.mergeWith(otherNote); + assertEquals("merged:\ncgeo note\n--\nSimple provider note", result.toString()); + assertPersonalNote(result, "cgeo note", "Simple provider note"); + } + + public static void testMixedMerge() { + Geocache cache1 = new Geocache(); // not stored + cache1.setPersonalNote("merged:\nSimple cgeo note\n--\nSimple provider note"); + PersonalNote myNote = new PersonalNote(cache1); + Geocache cache2 = new Geocache(); + cache2.setListId(StoredList.STANDARD_LIST_ID); // stored + cache2.setPersonalNote("Provider note"); + PersonalNote otherNote = new PersonalNote(cache2); + PersonalNote result = myNote.mergeWith(otherNote); + assertEquals("merged:\nSimple cgeo note\n--\nSimple provider note", result.toString()); + assertPersonalNote(result, "Simple cgeo note", "Simple provider note"); + result = otherNote.mergeWith(myNote); + assertEquals("merged:\nSimple cgeo note\n--\nProvider note", result.toString()); + assertPersonalNote(result, "Simple cgeo note", "Provider note"); + } + + private static void assertPersonalNote(final PersonalNote note, final String cgeoNote, final String providerNote) { + assertEquals(cgeoNote, note.getCgeoNote()); + assertEquals(providerNote, note.getProviderNote()); + } +} |
