MockHttpServletRequestBuilder reqBuilder = post("/api/maps/foo")
.contentType(MediaType.APPLICATION_JSON)
.content(obj.toString());
MockHttpServletRequest req = reqBuilder.buildRequest(new MockServletContext());
try {
new MapController(geoServer, new RecentObjectCache())
.create("foo", new JSONObj().put("name", "map1"), req);
fail();
}