File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
main/java/com/microsoft/graph/serializer
test/java/com/microsoft/graph/serializer Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -196,9 +196,10 @@ public <T> String serializeObject(final T serializableObject) {
196196 if (outJson .has (field .getName ())) {
197197 final Type [] interfaces = field .getType ().getGenericInterfaces ();
198198 for (Type interfaceType : interfaces ) {
199- if (interfaceType == IJsonBackedObject .class ) {
199+ if (interfaceType == IJsonBackedObject .class && outJson . get ( field . getName ()). isJsonObject () ) {
200200 try {
201- outJsonTree = getDataFromAdditionalDataManager (outJsonTree , field .get (serializableObject ));
201+ final JsonElement outdatedValue = outJson .remove (field .getName ());
202+ outJson .add (field .getName (), getDataFromAdditionalDataManager (outdatedValue .getAsJsonObject (), field .get (serializableObject )));
202203 } catch (IllegalAccessException ex ) {
203204 logger .logDebug ("Couldn't access prop" + field .getName ());
204205 }
Original file line number Diff line number Diff line change 33import static org .junit .Assert .assertEquals ;
44import static org .junit .Assert .assertNotNull ;
55import static org .junit .Assert .assertNull ;
6+ import static org .junit .Assert .assertTrue ;
67
78import org .junit .Before ;
89import org .junit .Test ;
910
11+ import okhttp3 .Request ;
12+
1013import com .google .gson .JsonElement ;
1114import com .google .gson .JsonObject ;
1215import com .google .gson .JsonParser ;
1316import com .google .gson .JsonPrimitive ;
17+ import com .microsoft .graph .functional .TestBase ;
18+ import com .microsoft .graph .http .HttpMethod ;
1419import com .microsoft .graph .logger .DefaultLogger ;
1520import com .microsoft .graph .models .extensions .Drive ;
1621import com .microsoft .graph .models .extensions .DriveItemCreateUploadSessionBody ;
@@ -66,7 +71,7 @@ public void testPropsAdditionalDataOnNonIJSONObjects() {
6671 final DriveItemCreateUploadSessionBody body = new DriveItemCreateUploadSessionBody ();
6772 body .item = upProps ;
6873 String serializedObject = serializer .serializeObject (body );
69- assertEquals ("{\" item\" :{\" name\" :\" vacation.gif\" } ,\" @microsoft.graph.conflictBehavior\" :\" rename\" }" , serializedObject );
74+ assertEquals ("{\" item\" :{\" name\" :\" vacation.gif\" ,\" @microsoft.graph.conflictBehavior\" :\" rename\" } }" , serializedObject );
7075 }
7176
7277 @ Test
You can’t perform that action at this time.
0 commit comments