test_class.declarator: geoServer
test_class.modifier: @Mock
test_class.original_string: @Mock
      GeoServer geoServer;
test_class.type: GeoServer
test_class.var_name: geoServer
test_class.declarator: recent
test_class.modifier: @Mock
test_class.original_string: @Mock
      RecentObjectCache recent;
test_class.type: RecentObjectCache
test_class.var_name: recent
test_class.declarator: ctrl
test_class.modifier: @InjectMocks
test_class.original_string: @InjectMocks
      LayerController ctrl;
test_class.type: LayerController
test_class.var_name: ctrl
test_class.declarator: mvc
test_class.original_string: MockMvc mvc;
test_class.type: MockMvc
test_class.var_name: mvc
test_class.file: geoserver/webapp/api-composer/src/test/java/com/boundlessgeo/geoserver/api/controllers/LayerControllerTest.java
test_class.identifier: LayerControllerTest
test_case.body: @Test
      public void testList() throws Exception {
          MockGeoServer.get().catalog()
              .workspace("foo", "http://scratch.org", true)
                  .layer("one").style().point().layer()
                    .featureType().defaults().store("one").workspace()
                  .layer("two").style().point().layer()
                    .featureType().defaults().store("two").workspace()
              .geoServer().build(geoServer);
  
          Catalog catalog = geoServer.getCatalog();
          final List<LayerInfo> layers = catalog.getLayers();
          Answer<CloseableIteratorAdapter<LayerInfo>> a = new Answer<CloseableIteratorAdapter<LayerInfo>>() {
              @Override
              public CloseableIteratorAdapter<LayerInfo> answer(InvocationOnMock invocation) throws Throwable {
                  return new CloseableIteratorAdapter<LayerInfo>(layers.iterator());
              }
          };
          
          when(catalog.list(eq(LayerInfo.class), eq(Predicates.and(Predicates.equal("resource.namespace.prefix",
                  "foo"), Predicates.fullTextSearch("o"))), isA(Integer.class), isA(Integer.class), isA(SortBy.class))).thenAnswer(a);
          
          when(catalog.count(eq(LayerInfo.class), eq(Predicates.and(Predicates.equal("resource.namespace.prefix",
                  "foo"), Predicates.fullTextSearch(""))))).thenReturn(layers.size());
          
          MvcResult result = mvc.perform(get("/app/api/layers/foo"))
              .andExpect(status().isOk())
              .andExpect(content().contentType(MediaType.APPLICATION_JSON))
              .andReturn();
  
          JSONObj obj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject();
          assertEquals(2, obj.integer("total").intValue());
          assertEquals(2, obj.integer("count").intValue());
          assertEquals(0, obj.integer("page").intValue());
  
          JSONArr arr = obj.array("layers");
          assertEquals(arr.size(), 2);
  
          Iterables.find(arr, new Predicate<Object>() {
              @Override
              public boolean apply(@Nullable Object o) {
                  return "one".equals(JSONWrapper.wrap(o).toObject().str("name"));
              }
          });
          Iterables.find(arr, new Predicate<Object>() {
              @Override
              public boolean apply(@Nullable Object o) {
                  return "two".equals(JSONWrapper.wrap(o).toObject().str("name"));
              }
          });
          
          //Meaningless to test sort order here, since iterator is provided by mockup
          result = mvc.perform(get("/app/api/layers/foo?page=0&count=10&sort=name:asc&filter=o"))
                  .andExpect(status().isOk())
                  .andExpect(content().contentType(MediaType.APPLICATION_JSON))
                  .andReturn();
          
          result = mvc.perform(get("/app/api/layers/foo?page=0&count=10&sort=invalidparameter:badrequest&filter=o"))
                  .andExpect(status().isBadRequest())
                  .andReturn();
  
      }
test_case.class_method_signature: LayerControllerTest.testList()
test_case.full_signature: @Test public void testList()
test_case.identifier: testList
test_case.invocations: build geoServer workspace store defaults featureType layer point style layer workspace store defaults featureType layer point style layer workspace catalog get getCatalog getLayers iterator thenAnswer when list eq eq and equal fullTextSearch isA isA isA thenReturn when count eq eq and equal fullTextSearch size andReturn andExpect andExpect perform get isOk status contentType content toObject read getContentAsString getResponse assertEquals intValue integer assertEquals intValue integer assertEquals intValue integer array assertEquals size find equals str toObject wrap find equals str toObject wrap andReturn andExpect andExpect perform get isOk status contentType content andReturn andExpect perform get isBadRequest status
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testList()
focal_class.declarator: LOG = Logging.getLogger(LayerController.class)
focal_class.modifier: static
focal_class.original_string: static Logger LOG = Logging.getLogger(LayerController.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: importer
focal_class.original_string: Importer importer;
focal_class.type: Importer
focal_class.var_name: importer
focal_class.file: geoserver/webapp/api-composer/src/main/java/com/boundlessgeo/geoserver/api/controllers/LayerController.java
focal_class.identifier: LayerController
focal_class.class_method_signature: LayerController.LayerController(GeoServer geoServer, RecentObjectCache recentCache, Importer importer)
focal_class.full_signature: @Autowired public  LayerController(GeoServer geoServer, RecentObjectCache recentCache, Importer importer)
focal_class.identifier: LayerController
focal_class.modifiers: @Autowired public
focal_class.parameters: (GeoServer geoServer, RecentObjectCache recentCache, Importer importer)
focal_class.signature:  LayerController(GeoServer geoServer, RecentObjectCache recentCache, Importer importer)
focal_class.class_method_signature: LayerController.list(@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req)
focal_class.full_signature: @RequestMapping(value="/{wsName:.+}", method = RequestMethod.GET) public @ResponseBody JSONObj list(@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req)
focal_class.identifier: list
focal_class.modifiers: @RequestMapping(value="/{wsName:.+}", method = RequestMethod.GET) public @ResponseBody
focal_class.parameters: (@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req)
focal_class.return: JSONObj
focal_class.signature: JSONObj list(@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req)
focal_class.class_method_signature: LayerController.create(@PathVariable String wsName, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.full_signature: @RequestMapping(value = "/{wsName:.+}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody JSONObj create(@PathVariable String wsName, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.identifier: create
focal_class.modifiers: @RequestMapping(value = "/{wsName:.+}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody
focal_class.parameters: (@PathVariable String wsName, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.return: JSONObj
focal_class.signature: JSONObj create(@PathVariable String wsName, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.class_method_signature: LayerController.createLayerFromLayer(JSONObj from, WorkspaceInfo ws, Catalog cat)
focal_class.full_signature:  LayerInfo createLayerFromLayer(JSONObj from, WorkspaceInfo ws, Catalog cat)
focal_class.identifier: createLayerFromLayer
focal_class.parameters: (JSONObj from, WorkspaceInfo ws, Catalog cat)
focal_class.return: LayerInfo
focal_class.signature: LayerInfo createLayerFromLayer(JSONObj from, WorkspaceInfo ws, Catalog cat)
focal_class.class_method_signature: LayerController.createLayerFromResource(JSONObj ref, WorkspaceInfo ws, Catalog cat)
focal_class.full_signature:  LayerInfo createLayerFromResource(JSONObj ref, WorkspaceInfo ws, Catalog cat)
focal_class.identifier: createLayerFromResource
focal_class.parameters: (JSONObj ref, WorkspaceInfo ws, Catalog cat)
focal_class.return: LayerInfo
focal_class.signature: LayerInfo createLayerFromResource(JSONObj ref, WorkspaceInfo ws, Catalog cat)
focal_class.class_method_signature: LayerController.copyStyle(LayerInfo l, WorkspaceInfo ws, Catalog cat)
focal_class.full_signature:  StyleInfo copyStyle(LayerInfo l, WorkspaceInfo ws, Catalog cat)
focal_class.identifier: copyStyle
focal_class.parameters: (LayerInfo l, WorkspaceInfo ws, Catalog cat)
focal_class.return: StyleInfo
focal_class.signature: StyleInfo copyStyle(LayerInfo l, WorkspaceInfo ws, Catalog cat)
focal_class.class_method_signature: LayerController.findUniqueStyleName(String name, WorkspaceInfo ws, Catalog cat)
focal_class.full_signature:  String findUniqueStyleName(String name, WorkspaceInfo ws, Catalog cat)
focal_class.identifier: findUniqueStyleName
focal_class.parameters: (String name, WorkspaceInfo ws, Catalog cat)
focal_class.return: String
focal_class.signature: String findUniqueStyleName(String name, WorkspaceInfo ws, Catalog cat)
focal_class.class_method_signature: LayerController.get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req)
focal_class.full_signature: @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req)
focal_class.identifier: get
focal_class.modifiers: @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) public @ResponseBody
focal_class.parameters: (@PathVariable String wsName, @PathVariable String name, HttpServletRequest req)
focal_class.return: JSONObj
focal_class.signature: JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req)
focal_class.class_method_signature: LayerController.delete(@PathVariable String wsName, @PathVariable String name)
focal_class.full_signature: @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void delete(@PathVariable String wsName, @PathVariable String name)
focal_class.identifier: delete
focal_class.modifiers: @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public
focal_class.parameters: (@PathVariable String wsName, @PathVariable String name)
focal_class.return: void
focal_class.signature: void delete(@PathVariable String wsName, @PathVariable String name)
focal_class.class_method_signature: LayerController.patch(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.full_signature: @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PATCH) public @ResponseBody JSONObj patch(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.identifier: patch
focal_class.modifiers: @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PATCH) public @ResponseBody
focal_class.parameters: (@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.return: JSONObj
focal_class.signature: JSONObj patch(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.class_method_signature: LayerController.put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.full_signature: @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.identifier: put
focal_class.modifiers: @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody
focal_class.parameters: (@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.return: JSONObj
focal_class.signature: JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req)
focal_class.class_method_signature: LayerController.update(LayerInfo layer, WorkspaceInfo ws, JSONObj obj, HttpServletRequest req)
focal_class.full_signature:  JSONObj update(LayerInfo layer, WorkspaceInfo ws, JSONObj obj, HttpServletRequest req)
focal_class.identifier: update
focal_class.parameters: (LayerInfo layer, WorkspaceInfo ws, JSONObj obj, HttpServletRequest req)
focal_class.return: JSONObj
focal_class.signature: JSONObj update(LayerInfo layer, WorkspaceInfo ws, JSONObj obj, HttpServletRequest req)
focal_class.class_method_signature: LayerController.computeNativeBounds(ResourceInfo r, Catalog catalog)
focal_class.full_signature: public void computeNativeBounds(ResourceInfo r, Catalog catalog)
focal_class.identifier: computeNativeBounds
focal_class.modifiers: public
focal_class.parameters: (ResourceInfo r, Catalog catalog)
focal_class.return: void
focal_class.signature: void computeNativeBounds(ResourceInfo r, Catalog catalog)
focal_class.class_method_signature: LayerController.computeLatLonBounds(ResourceInfo r, Catalog catalog)
focal_class.full_signature: public void computeLatLonBounds(ResourceInfo r, Catalog catalog)
focal_class.identifier: computeLatLonBounds
focal_class.modifiers: public
focal_class.parameters: (ResourceInfo r, Catalog catalog)
focal_class.return: void
focal_class.signature: void computeLatLonBounds(ResourceInfo r, Catalog catalog)
focal_class.class_method_signature: LayerController.style(@RequestBody byte[] rawStyle, @PathVariable String wsName,
          @PathVariable String name, @RequestParam(value="map", required=false) String mapName)
focal_class.full_signature: @RequestMapping(value="/{wsName}/{name}/style", method = RequestMethod.PUT, consumes = YsldHandler.MIMETYPE) @ResponseStatus(value = HttpStatus.OK) public void style(@RequestBody byte[] rawStyle, @PathVariable String wsName,
          @PathVariable String name, @RequestParam(value="map", required=false) String mapName)
focal_class.identifier: style
focal_class.modifiers: @RequestMapping(value="/{wsName}/{name}/style", method = RequestMethod.PUT, consumes = YsldHandler.MIMETYPE) @ResponseStatus(value = HttpStatus.OK) public
focal_class.parameters: (@RequestBody byte[] rawStyle, @PathVariable String wsName,
          @PathVariable String name, @RequestParam(value="map", required=false) String mapName)
focal_class.return: void
focal_class.signature: void style(@RequestBody byte[] rawStyle, @PathVariable String wsName,
          @PathVariable String name, @RequestParam(value="map", required=false) String mapName)
focal_class.class_method_signature: LayerController.createYsld(String name, WorkspaceInfo ws)
focal_class.full_signature: private StyleInfo createYsld(String name, WorkspaceInfo ws)
focal_class.identifier: createYsld
focal_class.modifiers: private
focal_class.parameters: (String name, WorkspaceInfo ws)
focal_class.return: StyleInfo
focal_class.signature: StyleInfo createYsld(String name, WorkspaceInfo ws)
focal_class.class_method_signature: LayerController.style(@PathVariable String wsName, @PathVariable String name)
focal_class.full_signature: @RequestMapping(value="/{wsName}/{name}/style", method = RequestMethod.GET, produces = YsldHandler.MIMETYPE) public @ResponseBody Object style(@PathVariable String wsName, @PathVariable String name)
focal_class.identifier: style
focal_class.modifiers: @RequestMapping(value="/{wsName}/{name}/style", method = RequestMethod.GET, produces = YsldHandler.MIMETYPE) public @ResponseBody
focal_class.parameters: (@PathVariable String wsName, @PathVariable String name)
focal_class.return: Object
focal_class.signature: Object style(@PathVariable String wsName, @PathVariable String name)
focal_class.class_method_signature: LayerController.error(InvalidYsldException e, HttpServletResponse response)
focal_class.full_signature: @ExceptionHandler(InvalidYsldException.class) public @ResponseBody JSONObj error(InvalidYsldException e, HttpServletResponse response)
focal_class.identifier: error
focal_class.modifiers: @ExceptionHandler(InvalidYsldException.class) public @ResponseBody
focal_class.parameters: (InvalidYsldException e, HttpServletResponse response)
focal_class.return: JSONObj
focal_class.signature: JSONObj error(InvalidYsldException e, HttpServletResponse response)
focal_class.class_method_signature: LayerController.recent(HttpServletRequest req)
focal_class.full_signature: @RequestMapping(value="/recent", method = RequestMethod.GET) public @ResponseBody JSONArr recent(HttpServletRequest req)
focal_class.identifier: recent
focal_class.modifiers: @RequestMapping(value="/recent", method = RequestMethod.GET) public @ResponseBody
focal_class.parameters: (HttpServletRequest req)
focal_class.return: JSONArr
focal_class.signature: JSONArr recent(HttpServletRequest req)
focal_class.class_method_signature: LayerController.layer(JSONObj obj, LayerInfo l, HttpServletRequest req)
focal_class.full_signature:  JSONObj layer(JSONObj obj, LayerInfo l, HttpServletRequest req)
focal_class.identifier: layer
focal_class.parameters: (JSONObj obj, LayerInfo l, HttpServletRequest req)
focal_class.return: JSONObj
focal_class.signature: JSONObj layer(JSONObj obj, LayerInfo l, HttpServletRequest req)
focal_class.class_method_signature: LayerController.findUniqueStyleName(String wsName, String name, Catalog cat)
focal_class.full_signature:  String findUniqueStyleName(String wsName, String name, Catalog cat)
focal_class.identifier: findUniqueStyleName
focal_class.parameters: (String wsName, String name, Catalog cat)
focal_class.return: String
focal_class.signature: String findUniqueStyleName(String wsName, String name, Catalog cat)
focal_class.superclass: extends ApiController
focal_method.body: @RequestMapping(value="/{wsName:.+}", method = RequestMethod.GET)
      public @ResponseBody
      JSONObj list(@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req) {
          JSONObj obj = new JSONObj();
  
          Catalog cat = geoServer.getCatalog();
  
          if ("default".equals(wsName)) {
              WorkspaceInfo def = cat.getDefaultWorkspace();
              if (def != null) {
                  wsName = def.getName();
              }
          }
          Filter filter = equal("resource.namespace.prefix", wsName);
          if (textFilter != null) {
              filter = Predicates.and(filter, Predicates.fullTextSearch(textFilter));
          }
          Integer total = cat.count(LayerInfo.class, filter);
  
          SortBy sortBy = parseSort(sort);
  
          obj.put("total", total);
          obj.put("page", page != null ? page : 0);
          obj.put("count", Math.min(total, count != null ? count : total));
  
          JSONArr arr = obj.putArray("layers");
          try (
              CloseableIterator<LayerInfo> it = cat.list(LayerInfo.class, filter, offset(page, count), count, sortBy);
          ) {
              while (it.hasNext()) {
                  layer(arr.addObject(), it.next(), req);
              }
          }
  
          return obj;
      }
focal_method.class_method_signature: LayerController.list(@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req)
focal_method.full_signature: @RequestMapping(value="/{wsName:.+}", method = RequestMethod.GET) public @ResponseBody JSONObj list(@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req)
focal_method.identifier: list
focal_method.invocations: getCatalog equals getDefaultWorkspace getName equal and fullTextSearch count parseSort put put put min putArray list offset hasNext layer addObject next
focal_method.modifiers: @RequestMapping(value="/{wsName:.+}", method = RequestMethod.GET) public @ResponseBody
focal_method.parameters: (@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req)
focal_method.return: JSONObj
focal_method.signature: JSONObj list(@PathVariable String wsName, 
              @RequestParam(value="page", required=false) Integer page,
              @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
              @RequestParam(value="sort", required=false) String sort, 
              @RequestParam(value="filter", required=false) String textFilter, 
              HttpServletRequest req)