Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
postcodes-io-java
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
James Coyle
postcodes-io-java
Commits
2a6a49d6
Commit
2a6a49d6
authored
Aug 14, 2016
by
Deepak Prabhakar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added few more tests for PostcodeLookup
parent
e5f4a015
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
365 additions
and
3 deletions
+365
-3
src/main/java/com/postcode/io/initializers/Postcode.java
src/main/java/com/postcode/io/initializers/Postcode.java
+1
-1
src/main/java/com/postcode/io/initializers/ReverseGeocoding.java
...n/java/com/postcode/io/initializers/ReverseGeocoding.java
+1
-1
src/test/java/com/postcode/io/initializers/PostcodeLookupTest.java
...java/com/postcode/io/initializers/PostcodeLookupTest.java
+7
-1
src/test/java/com/postcode/io/initializers/PostcodeTest.java
src/test/java/com/postcode/io/initializers/PostcodeTest.java
+21
-0
src/test/resources/reverseGeocodingWithAllParams.json
src/test/resources/reverseGeocodingWithAllParams.json
+335
-0
No files found.
src/main/java/com/postcode/io/initializers/Postcode.java
View file @
2a6a49d6
...
...
@@ -66,7 +66,7 @@ public class Postcode {
* @throws MalformedURLException
*/
public
PostcodeLookup
build
()
throws
MalformedURLException
{
if
(
postcode
!=
null
)
{
if
(
postcode
!=
null
&&
!
postcode
.
trim
().
isEmpty
()
)
{
return
new
PostcodeLookup
(
new
URL
(
LOOKUP_URL
.
toString
().
concat
(
postcode
)),
postcode
,
postcodes
);
}
else
if
(
postcode
==
null
&&
postcodes
!=
null
)
{
return
new
PostcodeLookup
(
new
URL
(
LOOKUP_URL
.
toString
()),
postcode
,
postcodes
);
...
...
src/main/java/com/postcode/io/initializers/ReverseGeocoding.java
View file @
2a6a49d6
...
...
@@ -204,7 +204,7 @@ public class ReverseGeocoding {
return
radius
;
}
p
ublic
static
boolean
isWideSearch
()
{
p
rivate
static
boolean
isWideSearch
()
{
return
wideSearch
;
}
...
...
src/test/java/com/postcode/io/initializers/PostcodeLookupTest.java
View file @
2a6a49d6
...
...
@@ -49,7 +49,6 @@ public class PostcodeLookupTest {
.
urlToJson
(
new
File
(
System
.
getProperty
(
"user.dir"
).
concat
(
"/src/test/resources/postcodeLookup.json"
))
.
toURI
().
toURL
()),
PostcodeLookup
.
postcode
(
"bs347np"
).
asJson
(),
JSONCompareMode
.
STRICT
);
}
@Test
...
...
@@ -87,6 +86,13 @@ public class PostcodeLookupTest {
assertTrue
(
PostcodeLookup
.
reverseGeocoding
(
0.629834723775309
,
51.7923246977375
).
asjson
().
has
(
"status"
));
assertTrue
(
PostcodeLookup
.
reverseGeocoding
(
0.629834723775309
,
51.7923246977375
).
asjson
().
getInt
(
"status"
)
==
200
);
JSONAssert
.
assertEquals
(
JsonFetcher
.
urlToJson
(
new
File
(
System
.
getProperty
(
"user.dir"
).
concat
(
"/src/test/resources/reverseGeocodingWithAllParams.json"
))
.
toURI
().
toURL
()),
PostcodeLookup
.
reverseGeocoding
(
0.629834723775309
,
51.7923246977375
).
limit
(
100
).
radius
(
2000
)
.
wideSearch
(
true
).
asjson
(),
JSONCompareMode
.
LENIENT
);
}
}
\ No newline at end of file
src/test/java/com/postcode/io/initializers/PostcodeTest.java
0 → 100644
View file @
2a6a49d6
package
com.postcode.io.initializers
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.net.MalformedURLException
;
import
org.junit.Test
;
public
class
PostcodeTest
{
@Test
public
void
testBuild
()
throws
MalformedURLException
{
Postcode
pc
=
new
Postcode
(
""
);
try
{
pc
.
build
();
}
catch
(
IllegalArgumentException
e
)
{
assertEquals
(
"postcode/postcodes are mandatory"
,
e
.
getMessage
());
}
}
}
src/test/resources/reverseGeocodingWithAllParams.json
0 → 100644
View file @
2a6a49d6
{
"status"
:
200
,
"result"
:
[
{
"postcode"
:
"CM8 1EF"
,
"quality"
:
1
,
"eastings"
:
581459
,
"northings"
:
213679
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.629805756141451
,
"latitude"
:
51.7923253460324
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017F"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1EF"
,
"outcode"
:
"CM8"
,
"distance"
:
1.999933684
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham South"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010388"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1EU"
,
"quality"
:
1
,
"eastings"
:
581508
,
"northings"
:
213652
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.630501346634837
,
"latitude"
:
51.7920669594304
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017F"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1EU"
,
"outcode"
:
"CM8"
,
"distance"
:
54.201577381
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham South"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010388"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1PH"
,
"quality"
:
1
,
"eastings"
:
581421
,
"northings"
:
213740
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.629287248592585
,
"latitude"
:
51.792885536147
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017H"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1PH"
,
"outcode"
:
"CM8"
,
"distance"
:
72.942852885
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham Central"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010386"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1PQ"
,
"quality"
:
1
,
"eastings"
:
581399
,
"northings"
:
213755
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.628976438454592
,
"latitude"
:
51.7930273886756
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017H"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1PQ"
,
"outcode"
:
"CM8"
,
"distance"
:
98.078477373
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham Central"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010386"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1DX"
,
"quality"
:
1
,
"eastings"
:
581469
,
"northings"
:
213561
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.629888915851468
,
"latitude"
:
51.7912622833122
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017F"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1DX"
,
"outcode"
:
"CM8"
,
"distance"
:
118.266954986
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham South"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010388"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1EN"
,
"quality"
:
1
,
"eastings"
:
581322
,
"northings"
:
213693
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.627828782756308
,
"latitude"
:
51.7924954789529
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 016A"
,
"msoa"
:
"Braintree 016"
,
"incode"
:
"1EN"
,
"outcode"
:
"CM8"
,
"distance"
:
139.698703748
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham Central"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010386"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1ET"
,
"quality"
:
1
,
"eastings"
:
581492
,
"northings"
:
213820
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.630357436760122
,
"latitude"
:
51.793581044085
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017H"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1ET"
,
"outcode"
:
"CM8"
,
"distance"
:
144.36268894
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham Central"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010386"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1XD"
,
"quality"
:
1
,
"eastings"
:
581559
,
"northings"
:
213570
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.631197134044156
,
"latitude"
:
51.7913139362243
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017G"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1XD"
,
"outcode"
:
"CM8"
,
"distance"
:
146.572911495
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham South"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010388"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1FY"
,
"quality"
:
1
,
"eastings"
:
581624
,
"northings"
:
213738
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.632226449173734
,
"latitude"
:
51.7928017472759
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017F"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1FY"
,
"outcode"
:
"CM8"
,
"distance"
:
173.343397689
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham South"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010388"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
},
{
"postcode"
:
"CM8 1AN"
,
"quality"
:
1
,
"eastings"
:
581412
,
"northings"
:
213512
,
"country"
:
"England"
,
"nhs_ha"
:
"East of England"
,
"longitude"
:
0.629037754187631
,
"latitude"
:
51.7908406614415
,
"parliamentary_constituency"
:
"Witham"
,
"european_electoral_region"
:
"Eastern"
,
"primary_care_trust"
:
"Mid Essex"
,
"region"
:
"East of England"
,
"lsoa"
:
"Braintree 017G"
,
"msoa"
:
"Braintree 017"
,
"incode"
:
"1AN"
,
"outcode"
:
"CM8"
,
"distance"
:
174.03432537
,
"admin_district"
:
"Braintree"
,
"parish"
:
"Witham"
,
"admin_county"
:
"Essex"
,
"admin_ward"
:
"Witham South"
,
"ccg"
:
"NHS Mid Essex"
,
"nuts"
:
"Essex Haven Gateway"
,
"codes"
:
{
"admin_district"
:
"E07000067"
,
"admin_county"
:
"E10000012"
,
"admin_ward"
:
"E05010388"
,
"parish"
:
"E04003939"
,
"ccg"
:
"E38000106"
,
"nuts"
:
"UKH34"
}
}
]
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment