-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86712f7
commit ab631b7
Showing
5 changed files
with
114 additions
and
12 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
45 changes: 45 additions & 0 deletions
45
hibernate3/src/test/java/com/fasterxml/jackson/datatype/hibernate3/OneToManyTest.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,45 @@ | ||
package com.fasterxml.jackson.datatype.hibernate3; | ||
|
||
import java.util.*; | ||
|
||
import javax.persistence.OneToMany; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class OneToManyTest extends BaseTest | ||
{ | ||
static final String EXPECTED_JSON = "{\"m\":{\"A\":\"A\"}}"; | ||
|
||
static final class X { | ||
@OneToMany | ||
public final Map<String, String> m = new LinkedHashMap<String, String>(); | ||
} | ||
|
||
static final class Y { | ||
public final Map<String, String> m = new LinkedHashMap<String, String>(); | ||
} | ||
|
||
public void testMap() throws Exception { | ||
Y object = new Y(); | ||
object.m.put("A", "A"); | ||
|
||
assertEquals(EXPECTED_JSON, mapWithoutHibernateModule(object)); | ||
assertEquals(EXPECTED_JSON, mapWithHibernateModule(object)); | ||
} | ||
|
||
public void testMapWithOneToMany() throws Exception { | ||
X object = new X(); | ||
object.m.put("A", "A"); | ||
|
||
assertEquals(EXPECTED_JSON, mapWithoutHibernateModule(object)); | ||
assertEquals(EXPECTED_JSON, mapWithHibernateModule(object)); | ||
} | ||
|
||
private String mapWithHibernateModule(Object object) throws Exception { | ||
return new ObjectMapper().registerModule(new Hibernate3Module()).writeValueAsString(object); | ||
} | ||
|
||
private String mapWithoutHibernateModule(Object object) throws Exception { | ||
return new ObjectMapper().writeValueAsString(object); | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
hibernate4/src/test/java/com/fasterxml/jackson/datatype/hibernate4/OneToManyTest.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,45 @@ | ||
package com.fasterxml.jackson.datatype.hibernate4; | ||
|
||
import java.util.*; | ||
|
||
import javax.persistence.OneToMany; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class OneToManyTest extends BaseTest | ||
{ | ||
static final String EXPECTED_JSON = "{\"m\":{\"A\":\"A\"}}"; | ||
|
||
static final class X { | ||
@OneToMany | ||
public final Map<String, String> m = new LinkedHashMap<String, String>(); | ||
} | ||
|
||
static final class Y { | ||
public final Map<String, String> m = new LinkedHashMap<String, String>(); | ||
} | ||
|
||
public void testMap() throws Exception { | ||
Y object = new Y(); | ||
object.m.put("A", "A"); | ||
|
||
assertEquals(EXPECTED_JSON, mapWithoutHibernateModule(object)); | ||
assertEquals(EXPECTED_JSON, mapWithHibernateModule(object)); | ||
} | ||
|
||
public void testMapWithOneToMany() throws Exception { | ||
X object = new X(); | ||
object.m.put("A", "A"); | ||
|
||
assertEquals(EXPECTED_JSON, mapWithoutHibernateModule(object)); | ||
assertEquals(EXPECTED_JSON, mapWithHibernateModule(object)); | ||
} | ||
|
||
private String mapWithHibernateModule(Object object) throws Exception { | ||
return new ObjectMapper().registerModule(new Hibernate4Module()).writeValueAsString(object); | ||
} | ||
|
||
private String mapWithoutHibernateModule(Object object) throws Exception { | ||
return new ObjectMapper().writeValueAsString(object); | ||
} | ||
} |
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