aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-11-18 09:54:03 +0100
committerBananeweizen <bananeweizen@gmx.de>2012-11-18 09:54:03 +0100
commit2e00c7a146e7718420be288e2073cc144d054f4f (patch)
tree5d32af3fb31a6d133f7a5f4b81792368248b7b39 /tests
parent1acd103d9c4a4104aa54ed3c2f693f80ba12a8a6 (diff)
downloadcgeo-2e00c7a146e7718420be288e2073cc144d054f4f.zip
cgeo-2e00c7a146e7718420be288e2073cc144d054f4f.tar.gz
cgeo-2e00c7a146e7718420be288e2073cc144d054f4f.tar.bz2
refactoring: lazy initialized lists
* change more users to only take Iterable interface * return unmodifiable list only
Diffstat (limited to 'tests')
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java7
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2CJPF.java7
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2JVEH.java6
-rw-r--r--tests/src/cgeo/geocaching/test/mock/MockedLazyInitializedList.java20
4 files changed, 29 insertions, 11 deletions
diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
index eb5fdbf..3b129cd 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
@@ -5,12 +5,11 @@ import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.utils.LazyInitializedList;
import java.text.ParseException;
-import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
@@ -104,7 +103,7 @@ public class GC1ZXX2 extends MockedCache {
}
@Override
- public List<String> getAttributes() {
+ public LazyInitializedList<String> getAttributes() {
String[] attributes = new String[] {
"bicycles_yes",
"available_yes",
@@ -114,7 +113,7 @@ public class GC1ZXX2 extends MockedCache {
"kids_yes",
"dogs_yes"
};
- return Arrays.asList(attributes);
+ return new MockedLazyInitializedList<String>(attributes);
}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
index 40bc0da..3805612 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
@@ -6,12 +6,11 @@ import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.utils.LazyInitializedList;
import java.text.ParseException;
-import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
@@ -130,7 +129,7 @@ public class GC2CJPF extends MockedCache {
}
@Override
- public List<String> getAttributes() {
+ public LazyInitializedList<String> getAttributes() {
String[] attributes = new String[] {
"motorcycles_no",
"wheelchair_no",
@@ -143,7 +142,7 @@ public class GC2CJPF extends MockedCache {
"bicycles_yes",
"dogs_yes"
};
- return Arrays.asList(attributes);
+ return new MockedLazyInitializedList<String>(attributes);
}
@Override
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
index 9f0b0a9..21e7f5f 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
@@ -7,10 +7,10 @@ import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.utils.LazyInitializedList;
import java.text.ParseException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -98,7 +98,7 @@ public class GC2JVEH extends MockedCache {
}
@Override
- public List<String> getAttributes() {
+ public LazyInitializedList<String> getAttributes() {
final String[] attributes = new String[] {
"winter_yes",
"flashlight_yes",
@@ -108,7 +108,7 @@ public class GC2JVEH extends MockedCache {
"hike_med_yes",
"rappelling_yes"
};
- return Arrays.asList(attributes);
+ return new MockedLazyInitializedList<String>(attributes);
}
@Override
diff --git a/tests/src/cgeo/geocaching/test/mock/MockedLazyInitializedList.java b/tests/src/cgeo/geocaching/test/mock/MockedLazyInitializedList.java
new file mode 100644
index 0000000..a3dd5e3
--- /dev/null
+++ b/tests/src/cgeo/geocaching/test/mock/MockedLazyInitializedList.java
@@ -0,0 +1,20 @@
+package cgeo.geocaching.test.mock;
+
+import cgeo.geocaching.utils.LazyInitializedList;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+class MockedLazyInitializedList<ElementType> extends LazyInitializedList<ElementType> {
+
+ public MockedLazyInitializedList(ElementType[] elements) {
+ set(Arrays.asList(elements));
+ }
+
+ @Override
+ protected List<ElementType> loadFromDatabase() {
+ return new ArrayList<ElementType>();
+ }
+
+}