Skip to content

Commit 6d7adf9

Browse files
committed
Formatting fixes
1 parent 78c77e7 commit 6d7adf9

File tree

2 files changed

+83
-83
lines changed

2 files changed

+83
-83
lines changed

hibernate4/src/test/java/tools/jackson/datatype/hibernate4/ReplacePersistentCollectionTest.java

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -19,104 +19,104 @@
1919

2020
import static org.junit.jupiter.api.Assertions.*;
2121

22-
public class ReplacePersistentCollectionTest {
23-
24-
private EntityManagerFactory emf;
25-
26-
private EntityManager em;
27-
28-
@BeforeEach
29-
public void setUp() throws Exception {
30-
emf = Persistence.createEntityManagerFactory("persistenceUnit");
31-
em = emf.createEntityManager();
32-
}
33-
34-
@AfterEach
35-
public void tearDown() throws Exception {
36-
em.close();
37-
emf.close();
38-
}
39-
40-
// [Issue#93], backwards compatible case
41-
@Test
42-
public void testNoReplacePersistentCollection() throws Exception {
43-
final ObjectMapper mapper = hibernateMapper(new Hibernate4Module()
44-
.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, true)
45-
);
46-
47-
Customer customer = em.find(Customer.class, 103);
48-
assertFalse(Hibernate.isInitialized(customer.getPayments()));
49-
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(customer);
50-
assertTrue(json.contains("org.hibernate.collection"));
51-
// should force loading...
52-
Set<Payment> payments = customer.getPayments();
53-
/*
22+
public class ReplacePersistentCollectionTest
23+
{
24+
private EntityManagerFactory emf;
25+
26+
private EntityManager em;
27+
28+
@BeforeEach
29+
public void setUp() throws Exception {
30+
emf = Persistence.createEntityManagerFactory("persistenceUnit");
31+
em = emf.createEntityManager();
32+
}
33+
34+
@AfterEach
35+
public void tearDown() throws Exception {
36+
em.close();
37+
emf.close();
38+
}
39+
40+
// [Issue#93], backwards compatible case
41+
@Test
42+
public void testNoReplacePersistentCollection() throws Exception {
43+
final ObjectMapper mapper = hibernateMapper(new Hibernate4Module()
44+
.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, true)
45+
);
46+
47+
Customer customer = em.find(Customer.class, 103);
48+
assertFalse(Hibernate.isInitialized(customer.getPayments()));
49+
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(customer);
50+
assertTrue(json.contains("org.hibernate.collection"));
51+
// should force loading...
52+
Set<Payment> payments = customer.getPayments();
53+
/*
5454
System.out.println("--- JSON ---");
5555
System.out.println(json);
5656
System.out.println("--- /JSON ---");
57-
*/
58-
59-
assertTrue(Hibernate.isInitialized(payments));
60-
// TODO: verify
61-
assertNotNull(json);
62-
63-
boolean exceptionThrown = false;
64-
try {
65-
/*Map<?, ?> stuff =*/ mapper.readValue(json, Map.class);
66-
} catch (DatabindException e) {
67-
exceptionThrown = true;
68-
}
69-
assertTrue(exceptionThrown);
70-
}
71-
72-
// [Issue#93], backwards compatible case
73-
@Test
74-
public void testReplacePersistentCollection() throws Exception {
75-
final ObjectMapper mapper = hibernateMapper(new Hibernate4Module()
76-
.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, true)
77-
.configure(Hibernate4Module.Feature.REPLACE_PERSISTENT_COLLECTIONS, true));
78-
79-
Customer customer = em.find(Customer.class, 103);
80-
assertFalse(Hibernate.isInitialized(customer.getPayments()));
81-
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(customer);
82-
assertFalse(json.contains("org.hibernate.collection"));
83-
// should force loading...
84-
Set<Payment> payments = customer.getPayments();
57+
*/
58+
59+
assertTrue(Hibernate.isInitialized(payments));
60+
// TODO: verify
61+
assertNotNull(json);
62+
63+
boolean exceptionThrown = false;
64+
try {
65+
/*Map<?, ?> stuff =*/ mapper.readValue(json, Map.class);
66+
} catch (DatabindException e) {
67+
exceptionThrown = true;
68+
}
69+
assertTrue(exceptionThrown);
70+
}
71+
72+
// [Issue#93], backwards compatible case
73+
@Test
74+
public void testReplacePersistentCollection() throws Exception {
75+
final ObjectMapper mapper = hibernateMapper(new Hibernate4Module()
76+
.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, true)
77+
.configure(Hibernate4Module.Feature.REPLACE_PERSISTENT_COLLECTIONS, true));
78+
79+
Customer customer = em.find(Customer.class, 103);
80+
assertFalse(Hibernate.isInitialized(customer.getPayments()));
81+
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(customer);
82+
assertFalse(json.contains("org.hibernate.collection"));
83+
// should force loading...
84+
Set<Payment> payments = customer.getPayments();
8585
/*
8686
System.out.println("--- JSON ---");
8787
System.out.println(json);
8888
System.out.println("--- /JSON ---");
8989
*/
9090

91-
assertTrue(Hibernate.isInitialized(payments));
92-
// TODO: verify
93-
assertNotNull(json);
91+
assertTrue(Hibernate.isInitialized(payments));
92+
// TODO: verify
93+
assertNotNull(json);
9494

9595
/*
9696
* Currently this cannot be verified due to Issue#94 default typing fails on 2.7.0 - 2.8.2-SNAPSHOT,
9797
* commented out until that is fixed.
9898
*/
9999

100-
boolean issue94failed = false;
101-
try {
102-
/* Map<?, ?> stuff =*/ mapper.readValue(json, Map.class);
103-
} catch (DatabindException e) {
104-
issue94failed = true;
105-
}
100+
boolean issue94failed = false;
101+
try {
102+
/* Map<?, ?> stuff =*/ mapper.readValue(json, Map.class);
103+
} catch (DatabindException e) {
104+
issue94failed = true;
105+
}
106106

107-
assertTrue(issue94failed, "If this fails, means #94 is fixed. Replace to the below commented lines");
107+
assertTrue(issue94failed, "If this fails, means #94 is fixed. Replace to the below commented lines");
108108

109109
// Map<?, ?> stuff = mapper.readValue(json, Map.class);
110110
//
111111
// assertTrue(stuff.containsKey("payments"));
112112
// assertTrue(stuff.containsKey("orders"));
113113
// assertNull(stuff.get("orderes"));
114-
}
115-
116-
private ObjectMapper hibernateMapper(Hibernate4Module module) {
117-
return JsonMapper.builder()
118-
.addModule(module)
119-
.activateDefaultTyping(new DefaultBaseTypeLimitingValidator(), DefaultTyping.NON_FINAL)
120-
.build();
121-
}
114+
}
115+
116+
private ObjectMapper hibernateMapper(Hibernate4Module module) {
117+
return JsonMapper.builder()
118+
.addModule(module)
119+
.activateDefaultTyping(new DefaultBaseTypeLimitingValidator(), DefaultTyping.NON_FINAL)
120+
.build();
121+
}
122122
}

hibernate5/src/test/java/tools/jackson/datatype/hibernate5/ReplacePersistentCollectionTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ public void setUp() throws Exception {
3333

3434
@AfterEach
3535
public void tearDown() throws Exception {
36-
em.close();
37-
emf.close();
36+
em.close();
37+
emf.close();
3838
}
3939

4040
// [Issue#93], backwards compatible case
4141
@Disabled // https://github.com/FasterXML/jackson-datatype-hibernate/issues/192
4242
@Test
4343
public void testNoReplacePersistentCollection() throws Exception {
44-
final ObjectMapper mapper = hibernateMapper(new Hibernate5Module()
45-
.configure(Hibernate5Module.Feature.FORCE_LAZY_LOADING, true)
46-
);
44+
final ObjectMapper mapper = hibernateMapper(new Hibernate5Module()
45+
.configure(Hibernate5Module.Feature.FORCE_LAZY_LOADING, true)
46+
);
4747

4848
Customer customer = em.find(Customer.class, 103);
4949
assertFalse(Hibernate.isInitialized(customer.getPayments()));

0 commit comments

Comments
 (0)