Skip to content

Commit

Permalink
test for JSON serialization from DB
Browse files Browse the repository at this point in the history
this is to prove that the JSON serialization can work with DB identifiers
  • Loading branch information
pahjbo committed Oct 24, 2024
1 parent 6d4ea49 commit da4eb64
Showing 1 changed file with 19 additions and 1 deletion.
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]).
*/
Expand Down Expand Up @@ -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);
}

}

0 comments on commit da4eb64

Please sign in to comment.