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
C
course-material
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
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
IT1901
course-material
Commits
08df1d16
Commit
08df1d16
authored
Oct 11, 2019
by
George Adrian Stoica
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-9-LatLong-meta-data' into issue-10-display-latlong-metadata-in-the-fx-ui
catching up with source branch
parents
77213dfd
cf713a59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
simpleexample2/core/src/main/java/simpleex/json/LatLongSerializer.java
...2/core/src/main/java/simpleex/json/LatLongSerializer.java
+1
-1
simpleexample2/core/src/test/java/simpleex/json/LatLongsJsonTest.java
...e2/core/src/test/java/simpleex/json/LatLongsJsonTest.java
+29
-0
No files found.
simpleexample2/core/src/main/java/simpleex/json/LatLongSerializer.java
View file @
08df1d16
...
...
@@ -56,8 +56,8 @@ public class LatLongSerializer extends JsonSerializer<LatLong> {
}
jsonGen
.
writeEndArray
();
}
jsonGen
.
writeEndObject
();
}
jsonGen
.
writeEndObject
();
}
}
simpleexample2/core/src/test/java/simpleex/json/LatLongsJsonTest.java
View file @
08df1d16
package
simpleex.json
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.util.Arrays
;
import
java.util.Iterator
;
...
...
@@ -59,6 +60,34 @@ public class LatLongsJsonTest {
assertEqualsIgnoreWhitespace
(
expectedJson
,
actualJson
);
}
@Test
public
void
testLatLongsMetaDataSerialization
()
{
final
LatLong
latLong
=
latLong1
();
final
MetaData
metaData
=
latLong
.
getMetaData
();
metaData
.
addTags
(
"aTag"
,
"bTag"
);
metaData
.
setProperty
(
"aProperty"
,
"aValue"
);
final
LatLongs
latLongs
=
new
LatLongs
(
latLong
);
try
{
final
String
actualJson
=
objectMapper
.
writeValueAsString
(
latLongs
);
final
String
expectedJson
=
"[{\"latitude\":63.1,\"longitude\":12.3,"
+
"\"metaData\":{\"tags\":[\"aTag\",\"bTag\"],\"properties\":[{\"name\":\"aProperty\",\"value\":\"aValue\"}]}}]"
;
assertEqualsIgnoreWhitespace
(
expectedJson
,
actualJson
);
}
catch
(
final
JsonProcessingException
e
)
{
Assert
.
fail
();
}
catch
(
final
Exception
e
)
{
Assert
.
fail
();
}
}
@Test
public
void
testLatLongsMetaDataDeserialization
()
throws
Exception
{
final
String
json
=
"[{\"latitude\":63.1,\"longitude\":12.3,"
+
"\"metaData\":{\"tags\":[\"aTag\",\"bTag\"],\"properties\":[{\"name\":\"aProperty\",\"value\":\"aValue\"}]}}]"
;
final
LatLongs
latLongs
=
objectMapper
.
readValue
(
json
,
LatLongs
.
class
);
Assert
.
assertEquals
(
1
,
latLongs
.
getLatLongCount
());
Assert
.
assertTrue
(
latLongs
.
getLatLong
(
0
).
hasMetaData
());
}
// relies on a certain order
private
void
check
(
final
Iterator
<
String
>
it
,
final
String
...
ss
)
{
final
Iterator
<
String
>
it1
=
Arrays
.
asList
(
ss
).
iterator
();
...
...
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