DepartmentAddressController extends BaseController implements CrudController<DepartmentAddressResource, DepartmentAddressResource> { @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{departmentId}/addresses", method = RequestMethod.POST) public DepartmentAddressResource createResource(@Valid @RequestBody final DepartmentAddressResource resource) { LOG.info("Creating department address: {}", resource); return facade.createResource(resource); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{departmentId}/addresses", method = RequestMethod.POST) DepartmentAddressResource createResource(@Valid @RequestBody final DepartmentAddressResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{departmentId}/addresses/{id}", method = RequestMethod.PUT) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final DepartmentAddressResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{departmentId}/addresses/{id}", method = RequestMethod.GET) DepartmentAddressResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{departmentId}/addresses/{id}", method = RequestMethod.DELETE) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{departmentId}/addresses", method = RequestMethod.GET) PagedResultResource<DepartmentAddressResource> getPagedResource(final PagedRequest<DepartmentAddressResource> request);  }
@Test public void testCreateDepartmentAddress() throws Exception { Long departmentId = 1L; Long id = 2L; DepartmentAddressResource departmentAddressResource = new DepartmentAddressResource(); departmentAddressResource.setId(id); String request = getJson(departmentAddressResource, true); String response = getJson(departmentAddressResource, false); when(facade.createResource(any(DepartmentAddressResource.class))).thenReturn(departmentAddressResource); mockMvc.perform(post("/departments/{departmentId}/addresses", departmentId) .contentType(MediaType.APPLICATION_JSON) .content(request)) .andExpect(status().isCreated()) .andExpect(content().string(response)); verify(facade).createResource(departmentAddressResource); }