From c13832974f5e004ce5dc02fb2047b73ae5b9f6c7 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Tue, 25 Dec 2012 22:47:26 +0100 Subject: fix #2292: parse "marked missing" --- main/res/values/strings.xml | 1 + .../src/cgeo/geocaching/connector/gc/GCParser.java | 6 +- main/src/cgeo/geocaching/enumerations/LogType.java | 1 + tests/res/raw/tb29ggq.htm | 1173 ++++++++++++++++++++ .../geocaching/connector/gc/TrackablesTest.java | 24 +- 5 files changed, 1198 insertions(+), 7 deletions(-) create mode 100644 tests/res/raw/tb29ggq.htm diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml index 94c2139..7c18065 100644 --- a/main/res/values/strings.xml +++ b/main/res/values/strings.xml @@ -78,6 +78,7 @@ Discovered Reviewer Note Retract Listing + Marked Missing Do Nothing Visited Dropped Off diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index d2896bd..60e6688 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -1249,8 +1249,6 @@ public abstract class GCParser { * * @param page * the HTML page to parse, already processed through {@link BaseUtils#replaceWhitespace} - * @param app - * if not null, the application to use to save the trackable * @return the parsed trackable, or null if none could be parsed */ static cgTrackable parseTrackable(final String page, final String possibleTrackingcode) { @@ -1397,7 +1395,9 @@ public abstract class GCParser { } // Apply the pattern for images in a trackable log entry against each full log (group(0)) - final Matcher matcherLogImages = GCConstants.PATTERN_TRACKABLE_LOG_IMAGES.matcher(matcherLogs.group(0)); + final String logEntry = matcherLogs.group(0); + System.out.println(logEntry); + final Matcher matcherLogImages = GCConstants.PATTERN_TRACKABLE_LOG_IMAGES.matcher(logEntry); /* * 1. Image URL * 2. Image title diff --git a/main/src/cgeo/geocaching/enumerations/LogType.java b/main/src/cgeo/geocaching/enumerations/LogType.java index f72b8f6..5918fe1 100644 --- a/main/src/cgeo/geocaching/enumerations/LogType.java +++ b/main/src/cgeo/geocaching/enumerations/LogType.java @@ -40,6 +40,7 @@ public enum LogType { MOVE_COLLECTION(69, "69", "unused_collection", R.string.log_movecollection), MOVE_INVENTORY(70, "70", "unused_inventory", R.string.log_moveinventory), RETRACT(25, "25", "retract listing", R.string.log_retractlisting), + MARKED_MISSING(16, "16", "marked missing", R.string.log_marked_missing, R.drawable.mark_red), UNKNOWN(0, "unknown", "", R.string.err_unknown, R.drawable.mark_red); // LogType not init. yet public final int id; diff --git a/tests/res/raw/tb29ggq.htm b/tests/res/raw/tb29ggq.htm new file mode 100644 index 0000000..4baba57 --- /dev/null +++ b/tests/res/raw/tb29ggq.htm @@ -0,0 +1,1173 @@ + + + + + + + (TB29GGQ) Travel Bug Dog Tag - Courageous Carrot + + + + + + + + + + + + +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +

+ Geocaching.com

+
+ +
+ +
+ +
+ +

+ Geocaching

+
+ + + +
+ +

+

+

+ + Hello, Bananeweizen (Sign Out)
+ Premium Member + + + 328 Caches Found + +

+ +
+ + +
+ + + + +
+ + +
+
+ + +
+ + + +
+ + + + +
+ + + x +
+ + +

+ Travel Bug Dog Tag + Courageous Carrot +

+ + + + + + + + + + + + + + + + + +
Trackable Options
+ notebook Found it? Log it!
+ alert Watch This Trackable Item
+ printer Print Info Sheet
+ map View in Google Earth
There are 5 users watching this listing.
+ +
+ +
+ Owner: +
+ +
+ Team RoKeT +
+ + + +
+ Released: +
+ +
+ Wednesday, 01 October 2008 +
+ + + + +
+ Origin: +
+ +
+ Northwest England, United Kingdom +
+ + + +
+ Recently Spotted:
+ +
+ In Ihr Ziel befindet sich rechts (Airport TB-Hotel)
+ +
+

+ +

+

+ The owner hasn't set their collectible preference. +

+

+ Use TB29GGQ to reference this item. +

+

+ + First time logging a Trackable? Click here. + +

+

+ Current GOAL +

+
+

+ I am part of a gang of vegetables (see pic)
I want to travel and have adventures. Please help me! I love pics of my exploits too!
Move me on far and fast and help me have FUN! +

+
+

+ About This Item +

+
+

+ The gang! +

+

+ Mad looking carrot +

+
+
+ +

+ + +

+ +
+ +
+
+

+

Gallery Images related to Courageous Carrot

View All 5 Gallery Images

+ +

+ Tracking History (5753.9km ) View Map +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Dropped Off 2012-12-22 + + r.burton placed it in Ihr Ziel befindet sich rechts (Airport TB-Hotel) + + Nordrhein-Westfalen, Germany +   + + Visit Log +
+
+ + +
+ Retrieve It from a Cache 2012-12-22 + + r.burton retrieved it from Ihr Ziel befindet sich rechts (Airport TB-Hotel) + + Nordrhein-Westfalen, Germany +   + + Visit Log +
+
Seen at the Airport-Hotel in Dusseldorf/Germany...!
+ + +
+ Dropped Off 2012-12-21 + + silizius83 placed it in Ihr Ziel befindet sich rechts (Airport TB-Hotel) + + Nordrhein-Westfalen, Germany + - 788.16 km  + + Visit Log +
+
Dropped in Ihr Ziel befindet sich rechts (Airport TB-Hotel) (GC1X9FR)
+ + +
+ Grab It (Not from a Cache) 2012-12-20 + + silizius83 grabbed it + + +   + + Visit Log +
+
It tuc some time but now its time to release this one,
+ + +
+ Mark Missing 2012-11-04 + + holler2 marked it as missing + + +   + + Visit Log +
+
This is an automated message.
This Trackable has been marked 'missing' by a cache owner or site administrator. Trackables are marked missing when it is determined that they are no longer located in the cache they are listed in or in the hands of the current holder. Review the most recent logs on this Trackable to learn more information about its current state.
+ + +
+ Write note 2012-11-04 + + cezanne posted a note for it + + +   + + Visit Log +
+
Apparently someone took this TB to an event which took place in Burgenland and forgot to log it out of this cache. The TB was already missing from this cache on September 16 while the event took place on September 22.
+ + +
+ Discovered It 2012-09-22 + + cache-diver discovered it + + +   + + Visit Log +
+
Beim 8.Stammtisch der Südburgenländer gesehen!
+ + +
+ Discovered It 2012-09-22 + + Steirerposti discovered it + + +   + + Visit Log +
+
heute gesehen beim Straussen-Event der SBL !!
+ + +
+ Discovered It 2012-09-22 + + cosmo1355 discovered it + + +   + + Visit Log +
+
Gesehen beim Straussenevent
+ + +
+ Write note 2012-09-16 + + juchuuu posted a note for it + + +   + + Visit Log +
+
Nicht mehr im Cache vorhanden!!!! Nicht gesehen!!!
+ + +
+ data on this page is cached for 3 mins +
+ + + +

+ +

+ + + + + +
+ +
+ +
+ + +

+

+

+ + Advertising with Us

+ + +
+ + +
+ + +
+ + +
+ + + + + + + + +
+ + + + + + + + + +
+ + + +
+ + + + + diff --git a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java index 357c0cc..4c2655d 100644 --- a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java @@ -4,6 +4,7 @@ import cgeo.geocaching.LogEntry; import cgeo.geocaching.TrackableLog; import cgeo.geocaching.cgImage; import cgeo.geocaching.cgTrackable; +import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; import cgeo.geocaching.test.R; import cgeo.geocaching.utils.BaseUtils; @@ -71,7 +72,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { } public void testParseTrackableWithoutReleaseDate() { - cgTrackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb14wfv), null); + cgTrackable trackable = parseTrackable(R.raw.tb14wfv); assertNotNull(trackable); assertEquals("The Brickster", trackable.getName()); assertEquals("Adrian C", trackable.getOwner()); @@ -84,7 +85,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { } public void testParseRelativeLink() { - final cgTrackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb4cwjx), null); + final cgTrackable trackable = parseTrackable(R.raw.tb4cwjx); assertNotNull(trackable); assertEquals("The Golden Lisa", trackable.getName()); final String goal = trackable.getGoal(); @@ -93,12 +94,27 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { assertTrue(goal.contains("href=\"http://www.geocaching.com/seek/cache_details.aspx?wp=GC3B7PD#\"")); } + private cgTrackable parseTrackable(int trackablePage) { + String pageContent = getFileContent(trackablePage); + return GCParser.parseTrackable(BaseUtils.replaceWhitespace(pageContent), null); + } + + public void testParseMarkMissing() { + final cgTrackable trackable = parseTrackable(R.raw.tb29ggq); + assertNotNull(trackable); + final List logs = trackable.getLogs(); + assertNotNull(logs); + assertFalse(logs.isEmpty()); + LogEntry marked = logs.get(4); + assertEquals(LogType.MARKED_MISSING, marked.type); + } + private cgTrackable getTB2R124() { - return GCParser.parseTrackable(BaseUtils.replaceWhitespace(getFileContent(R.raw.trackable_tb2r124)), null); + return parseTrackable(R.raw.trackable_tb2r124); } private cgTrackable getTBXATG() { - return GCParser.parseTrackable(BaseUtils.replaceWhitespace(getFileContent(R.raw.trackable_tbxatg)), null); + return parseTrackable(R.raw.trackable_tbxatg); } public void testParseTrackableNotExisting() { -- cgit v1.1