56
56
import com .microsoft .azure .documentdb .User ;
57
57
import com .microsoft .azure .documentdb .UserDefinedFunction ;
58
58
59
+ final class AnotherPOJO {
60
+ public String pojoProp = "789" ;
61
+ }
62
+
59
63
public final class GatewayTests {
60
64
static final String HOST = "[YOUR_ENDPOINT_HERE]" ;
61
65
static final String MASTER_KEY = "[YOUR_KEY_HERE]" ;
@@ -193,7 +197,7 @@ private static String getStringFromInputStream(InputStream is) {
193
197
}
194
198
195
199
static class StaticPOJOForTest {
196
- // Jackson's readValue method only supports static and non-local POJO .
200
+ // Jackson's readValue method supports member class only if it's static .
197
201
public String pojoProp = "456" ;
198
202
}
199
203
@@ -207,6 +211,7 @@ public void testJsonSerialization() {
207
211
document .set ("child2" , new JSONObject ("{'child2Prop1': '800'}" ));
208
212
209
213
document .set ("child3" , new StaticPOJOForTest ());
214
+ document .set ("child4" , new AnotherPOJO ());
210
215
// Collection of numbers.
211
216
Collection <Integer > collection1 = new ArrayList <Integer >();
212
217
collection1 .add (101 );
@@ -242,6 +247,9 @@ public void testJsonSerialization() {
242
247
" 'child3': {" +
243
248
" 'pojoProp': '456'" +
244
249
" }," +
250
+ " 'child4': {" +
251
+ " 'pojoProp': '789'" +
252
+ " }," +
245
253
" 'collection1': [101, 102]," +
246
254
" 'collection2': [{'foo': 'bar'}]," +
247
255
" 'collection3': [{'pojoProp': '456'}]," +
@@ -250,6 +258,7 @@ public void testJsonSerialization() {
250
258
Assert .assertEquals (expectedDocument .toString (), document .toString ());
251
259
252
260
Assert .assertEquals ("456" , document .getObject ("child3" , StaticPOJOForTest .class ).pojoProp );
261
+ Assert .assertEquals ("789" , document .getObject ("child4" , AnotherPOJO .class ).pojoProp );
253
262
Assert .assertEquals ("456" , document .getCollection ("collection3" ,
254
263
StaticPOJOForTest .class ).iterator ().next ().pojoProp );
255
264
@@ -1242,7 +1251,7 @@ public void testOfferReadAndQuery() throws DocumentClientException {
1242
1251
1243
1252
// Modify the SelfLink
1244
1253
String offerLink = expectedOffer .getSelfLink ().substring (
1245
- 0 , expectedOffer .getSelfLink ().length () - 1 ) + "x" ;
1254
+ 0 , expectedOffer .getSelfLink ().length () - 1 ) + "x" ;
1246
1255
1247
1256
// Read the offer
1248
1257
try {
0 commit comments