Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Fix error from update to LDPath response
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Woods committed Mar 22, 2014
1 parent ff6c63a commit 4fe5acd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Expand Up @@ -46,7 +46,7 @@
*/
public class NamedFieldsDeserializer extends TypeAdapter<NamedFields> {

private static final Type type = new TypeToken<Collection<Map<String, JsonElement>>>() {}
private static final Type type = new TypeToken<Map<String, JsonElement>>() {}
.getType();

private Gson gson;
Expand Down Expand Up @@ -81,11 +81,8 @@ public void write(final JsonWriter out, final NamedFields value)
public NamedFields read(final JsonReader in)
throws IOException {
try {
final Collection<Map<String, JsonElement>> fields =
gson.fromJson(in, type);
// note: we assume that only one element will exist in
// fields, because that is the nature of the LDPath machinery
return new NamedFields(transformValues(fields.iterator().next(), jsonElement2list));
final Map<String, JsonElement> fields = gson.fromJson(in, type);
return new NamedFields(transformValues(fields, jsonElement2list));
} catch (final Exception e) {
LOGGER.error("Failed to parse JSON to Map<String, Collection<String>>!", e);
throw e;
Expand Down
Expand Up @@ -39,7 +39,7 @@ public void testWrite() throws IOException {
@Test
public void testReadGoodJson() throws IOException{
final String testUri = "testUri";
final String fakeJson = "[{\"id\" : [\"" + testUri + "\"]}]";
final String fakeJson = "{\"id\" : [\"" + testUri + "\"]}";
LOGGER.debug("Using fake JSON: {}", fakeJson);
try (
Reader r = new StringReader(fakeJson);
Expand All @@ -53,7 +53,7 @@ public void testReadGoodJson() throws IOException{
@Test(expected=IllegalStateException.class)
public void testReadBadJson() throws IOException{
final String testUri = "testUri";
final String fakeJson = "[{\"id\" : \"" + testUri + "\"}]";
final String fakeJson = "{\"id\" : \"" + testUri + "\"}";
LOGGER.debug("Using fake JSON: {}", fakeJson);
try (
Reader r = new StringReader(fakeJson);
Expand Down
Expand Up @@ -132,7 +132,7 @@ public void testGoodTransform() throws IOException {
when(mockClient.execute(any(HttpUriRequest.class))).thenReturn(
mockResponse);
when(mockStatusLine.getStatusCode()).thenReturn(SC_OK);
final String fakeJson = "[{\"id\" : [\"" + testUri + "\"]}]";
final String fakeJson = "{\"id\" : [\"" + testUri + "\"]}";
LOGGER.debug("Using fake JSON: {}", fakeJson);
try (
InputStream mockJson =
Expand Down

0 comments on commit 4fe5acd

Please sign in to comment.