forked from JavaOPs/topjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestUtil.java
More file actions
31 lines (25 loc) · 864 Bytes
/
Copy pathTestUtil.java
File metadata and controls
31 lines (25 loc) · 864 Bytes
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
package ru.javawebinar.topjava;
import org.springframework.test.web.servlet.ResultActions;
import ru.javawebinar.topjava.matcher.ModelMatcher;
import java.io.UnsupportedEncodingException;
/**
* GKislin
* 05.01.2015.
*/
public class TestUtil {
public static ResultActions print(ResultActions action) throws UnsupportedEncodingException {
System.out.println(getContent(action));
return action;
}
public static String getContent(ResultActions action) throws UnsupportedEncodingException {
return action.andReturn().getResponse().getContentAsString();
}
/**
* Compare entities using toString
*/
public static class ToStringModelMatcher<T> extends ModelMatcher<T, String> {
public ToStringModelMatcher(Class<T> entityClass) {
super(Object::toString, entityClass);
}
}
}