-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJSONTest.java
More file actions
41 lines (36 loc) · 1.41 KB
/
JSONTest.java
File metadata and controls
41 lines (36 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.omg.sysml;
import org.junit.Test;
import org.omg.sysml.model.Commit;
import java.lang.reflect.Type;
import static org.junit.Assert.*;
public class JSONTest {
private final JSON json = new JSON();
/**
* Tests JSON deserialization with a Commit provided in a string in JSON format.
*/
@Test
public void testJsonDeserialization() {
String elementId = "13ca289c-b7fe-4f41-a639-1e8f9b3199d5";
String jsonString =
"{" +
"\"@id\":\"36391e9a-8ab2-4a1a-bd6f-93edd0361c5f\"," +
"\"@type\":\"Commit\"," +
"\"change\":[" +
"{" +
"\"identity\":{" +
"\"@id\":\"" + elementId + "\"," +
"\"@type\":\"DataIdentity\"" +
"}," +
"\"payload\":{" +
"\"@type\":\"ActionDefinition\"," +
"\"@id\":\"" + elementId + "\"," +
"\"elementId\":\"" + elementId + "\"" +
"}" +
"}" +
"]" +
"}";
Type type = Commit.class;
Commit commit = json.deserialize(jsonString, type);
assertEquals(elementId, commit.getChange().get(0).getPayload().get("elementId"));
}
}