@RequestMapping( value = Routes.RETAIL_CUSTOMER_MEMBER, method = RequestMethod.PUT, consumes = "application/atom+xml", produces = "application/atom+xml") @ResponseBody public void update( HttpServletResponse response, @PathVariable Long applicationInformationId, @RequestParam Map<String, String> params, InputStream stream) throws IOException, FeedException { RetailCustomer retailCustomer = retailCustomerService.findById(applicationInformationId); if (retailCustomer != null) { try { RetailCustomer newRetailCustomer = retailCustomerService.importResource(stream); retailCustomer.merge(newRetailCustomer); } catch (Exception e) { System.out.printf( "***** Error Caused by RetailCustomer.x.IndentifiedObject need: %s", e.toString()); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } } }
@Test @Ignore public void show_setsMeterReadingModel() throws JAXBException { MeterReading meterReading = Factory.newMeterReading(); ModelMap model = new ModelMap(); RetailCustomer retailCustomer = EspiFactory.newRetailCustomer(); retailCustomer.setId(99L); when(service.findById(1L)).thenReturn(meterReading); controller.show(1L, 1L, 1L, model); assertEquals(meterReading, model.get("meterReading")); }
@RequestMapping( value = Routes.RETAIL_CUSTOMER_COLLECTION, method = RequestMethod.POST, consumes = "application/atom+xml", produces = "application/atom+xml") @ResponseBody public void create( HttpServletResponse response, @RequestParam Map<String, String> params, InputStream stream) throws IOException { response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE); try { RetailCustomer retailCustomer = this.retailCustomerService.importResource(stream); exportService.exportTimeConfiguration( retailCustomer.getId(), response.getOutputStream(), new ExportFilter(new HashMap<String, String>())); } catch (Exception e) { System.out.printf( "***** Error Caused by RetailCustomer.x.IndentifiedObject need: %s", e.toString()); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }