package com.tickets.web.controller;

import com.tickets.business.entities.ErrorResult;
import com.tickets.business.entities.RestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Controller of RESTFul web service.
 */
@RestController
@RequestMapping("/resource")
public class WebServiceController {
    private static final Logger LOG = LoggerFactory.getLogger("tickets");

    @RequestMapping(path = "/testRest", method = RequestMethod.GET)
    public RestResult testRest(HttpServletRequest request, HttpServletResponse response) {
        LOG.info(request.getMethod() + " " + request.getRequestURI());
        response.setStatus(200);
        RestResult result = new RestResult();
        result.put("username:", "tickets");
        result.put("password:", "123456");
        return result;
    }

    @RequestMapping(path = "/testError", method = RequestMethod.GET)
    public RestResult testError(HttpServletRequest request, HttpServletResponse response) {
        LOG.info(request.getMethod() + " " + request.getRequestURI());
        response.setStatus(404);
        return new ErrorResult("Oops! An error occurs.");
    }

}

@@ -515,16 +515,76 @@
 esponse;
+%0Aimport java.util.ArrayList;%0Aimport java.util.LinkedHashMap;
 %0A%0A/**%0A *
@@ -1171,24 +1171,312 @@
  %22123456%22);%0A
+        ArrayList%3CObject%3E data = new ArrayList%3CObject%3E();%0A        data.add(%22string%22);%0A        data.add(666);%0A        LinkedHashMap%3CString, Object%3E map = new LinkedHashMap%3CString, Object%3E();%0A        map.put(%22key%22, %22value%22);%0A        data.add(map);%0A        result.put(%22list_of_data%22, data);%0A
         retu

Add nested RESTFul result test