-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github.com//issues/65 github.com//issues/67
- Loading branch information
Showing
6 changed files
with
118 additions
and
10 deletions.
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
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
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
42 changes: 42 additions & 0 deletions
42
jackson/src/test/java/eu/mihosoft/vmf/jackson/test/renameprops01/RenamePropsModelTest.java
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package eu.mihosoft.vmf.jackson.test.renameprops01; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import eu.mihosoft.vmf.jackson.VMFJacksonModule; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class RenamePropsModelTest { | ||
|
||
@org.junit.jupiter.api.Test | ||
void testModel() throws JsonProcessingException { | ||
|
||
RenamePropsModel model = RenamePropsModel.newBuilder() | ||
.withCOMPort("COM1") | ||
.build(); | ||
|
||
var mapper = new ObjectMapper(); | ||
mapper.registerModule(VMFJacksonModule.newInstance(VMFJacksonModule.RUNTIME_TYPE.EXPERIMENTAL) | ||
.withTypeAlias("rename-props-model", RenamePropsModel.class.getName()) | ||
); | ||
|
||
|
||
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model); | ||
System.out.println(json); | ||
|
||
// deserialize | ||
RenamePropsModel model2 = mapper.readValue(json, RenamePropsModel.class); | ||
|
||
// serialize again | ||
String json2 = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model2); | ||
System.out.println(json2); | ||
|
||
assertEquals(json, json2); | ||
|
||
// check if deserialization worked | ||
assertTrue(model.vmf().content().equals(model2)); | ||
|
||
|
||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
jackson/src/test/vmf/eu/mihosoft/vmf/jackson/test/renameprops01/vmfmodel/RenameProps.java
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package eu.mihosoft.vmf.jackson.test.renameprops01.vmfmodel; | ||
|
||
import eu.mihosoft.vmf.core.Annotation; | ||
|
||
interface RenamePropsModel { | ||
|
||
// We want to prevent the property from being called "cOMPort" in the generated JSON | ||
@Annotation(key = "vmf:jackson:rename", value = "comPort") | ||
String getCOMPort(); | ||
|
||
} |