-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is to prove that the JSON serialization can work with DB identifiers
- Loading branch information
Showing
1 changed file
with
19 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
package org.ivoa.dm.serializationsample; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jakarta.persistence.EntityManager; | ||
|
||
/* | ||
* Created on 16/05/2023 by Paul Harrison ([email protected]). | ||
*/ | ||
|
@@ -68,5 +74,17 @@ protected String setDbDumpFile() { | |
return "serialization_dump.sql"; | ||
|
||
} | ||
@Test | ||
public void DBandJsonRoundTest() throws JsonProcessingException | ||
{ | ||
MyModelModel model = createModel(); | ||
RoundTripResult<SomeContent> ret = roundtripRDB(model.management(), model.getContent(SomeContent.class).get(0)); | ||
ObjectMapper mapper = model.management().jsonMapper(); | ||
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(ret.retval); | ||
System.out.println("JSON output"); | ||
System.out.println(json); | ||
SomeContent retval = mapper.readValue(json, SomeContent.class); | ||
assertNotNull(retval); | ||
} | ||
|
||
} |