import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void testIncludeNestedWithDefault() throws Exception {
Node root = new Node(1L, null, null);
Locale engLocale = new Locale(1L, java.util.Locale.ENGLISH);
Node child1 = new Node(2L, root, Collections.emptySet());
NodeComment child1Comment = new NodeComment(1L, "Child 1", child1, engLocale);
child1.setNodeComments(new LinkedHashSet<>(Collections.singleton(child1Comment)));
Node child2 = new Node(3L, root, Collections.emptySet(), Collections.emptySet());
root.setChildren(new LinkedHashSet<>(Arrays.asList(child1, child2)));
nodeRepository.save(root);
nodeRepository.save(child1);
nodeRepository.save(child2);
MockHttpServletRequest request = new MockHttpServletRequest(servletContext);
request.setMethod("GET");
request.setServletPath("/api");
request.setPathInfo("/nodes/1");
request.setRequestURI("/api/nodes/1");
request.setQueryString("include[nodes]=children.nodeComments");
request.setContentType(HttpHeaders.JSONAPI_CONTENT_TYPE);
Map params = new HashMap<>();
params.put("include[nodes]", "children.nodeComments.langLocale");
request.setParameters(params);
request.addHeader("Accept", "*/*");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
String responseContent = response.getContentAsString();
assertTopLevelNodesCorrectWithChildren(responseContent);
}