Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gson type adapters generated, good milestone #74
refined Constitution and defaults behaviour #71
- Loading branch information
Showing
13 changed files
with
248 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
gson/test/org/immutables/gson/adapters/AdaptReadWriteTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
package org.immutables.gson.adapters; | |||
|
|||
import com.google.common.collect.ImmutableSet; | |||
import com.google.gson.Gson; | |||
import com.google.gson.GsonBuilder; | |||
import org.junit.Test; | |||
import static org.immutables.check.Checkers.*; | |||
|
|||
public class AdaptReadWriteTest { | |||
|
|||
private final Gson gson = new GsonBuilder() | |||
.registerTypeAdapterFactory(new AdaptTypeAdapters()) | |||
.setPrettyPrinting() | |||
.create(); | |||
|
|||
private final Adapt adapt = | |||
ImmutableAdapt.of(ImmutableSet.of( | |||
ImmutableAdapt.Inr.builder() | |||
.addList(1, 2, 4) | |||
.putMap("key", ImmutableAdapt.Nst.builder() | |||
.string("a") | |||
.value(1) | |||
.build()) | |||
.putMap("other", ImmutableAdapt.Nst.builder() | |||
.string("b") | |||
.value(2) | |||
.build()) | |||
.build(), | |||
ImmutableAdapt.Inr.builder() | |||
.addList(5, 6) | |||
.putMap("ku", ImmutableAdapt.Nst.builder() | |||
.string("x") | |||
.value(11) | |||
.build()) | |||
.putMap("la", ImmutableAdapt.Nst.builder() | |||
.string("y") | |||
.value(21) | |||
.build()) | |||
.build())); | |||
|
|||
@Test | |||
public void adapt() { | |||
String json = gson.toJson(adapt); | |||
|
|||
System.out.println(json); | |||
Adapt instance = gson.fromJson(json, Adapt.class); | |||
|
|||
check(instance).is(adapt); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.