-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathModuleTestBase.java
More file actions
57 lines (47 loc) · 1.61 KB
/
ModuleTestBase.java
File metadata and controls
57 lines (47 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.openapitools.jackson.nullable;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.fail;
abstract class ModuleTestBase
{
/*
/**********************************************************************
/* Helper methods, setup
/**********************************************************************
*/
protected ObjectMapper mapperWithModule()
{
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JsonNullableModule());
return mapper;
}
protected ObjectMapper mapperWithModule(JsonNullableModule module)
{
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(module);
return mapper;
}
/*
/**********************************************************************
/* Helper methods, setup
/**********************************************************************
*/
protected void verifyException(Throwable e, String... matches)
{
String msg = e.getMessage();
String lmsg = (msg == null) ? "" : msg.toLowerCase();
for (String match : matches) {
String lmatch = match.toLowerCase();
if (lmsg.indexOf(lmatch) >= 0) {
return;
}
}
fail("Expected an exception with one of substrings ("+ Arrays.asList(matches)+"): got one with message \""+msg+"\"");
}
protected String quote(String str) {
return '"'+str+'"';
}
protected String aposToQuotes(String json) {
return json.replace("'", "\"");
}
}