AdminUnitController extends BaseController implements CrudController<AdminUnitResource, AdminUnitResource> { @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create Admin Unit") public AdminUnitResource createResource(@Valid @RequestBody final AdminUnitResource resource) { LOG.info("Creating Admin Unit: {}", resource); return facade.createResource(resource); }  @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Get Admin Unit Types") PagedResultResource<AdminUnitResource> getPagedResource(final PagedRequest<AdminUnitResource> request); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get Admin Unit by id") AdminUnitResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create Admin Unit") AdminUnitResource createResource(@Valid @RequestBody final AdminUnitResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.PUT) @ApiOperation(value = "Update Admin Unit") MessageResource updateResource(@PathVariable("id") final Long id, @Valid @RequestBody final AdminUnitResource resource); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = Request.ID, method = RequestMethod.DELETE) @ApiOperation(value = "Delete Admin Unit by id") MessageResource removeResource(@PathVariable("id") final Long id);  }
@Test public void testCreateAdminUnit() throws Exception { AdminUnitResource adminUnitResource = new AdminUnitResource(); String request = getJson(adminUnitResource, true); String response = getJson(adminUnitResource, false); when(facade.createResource(any(AdminUnitResource.class))).thenReturn(adminUnitResource); mockMvc.perform(post("/adminunits") .contentType(MediaType.APPLICATION_JSON) .content(request)) .andExpect(status().isCreated()) .andExpect(content().string(response)); verify(facade).createResource(adminUnitResource); }