@Test public void testGenerateCSVBody() throws Exception { final ContactPosition contactPosition = new ContactPosition(); contactPosition.setActive(true); contactPosition.setName("Ana Sánchez "); contactPosition.setPosition("Responsable de dirección "); contactPosition.setOrganization("A.T.R.I.L CB"); contactPosition.setDepartment("Indefinido"); final List<ContactPosition> contactPositions = new ArrayList<ContactPosition>(); contactPositions.add(contactPosition); final Map<String, String> texts = new HashMap<String, String>(); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_NAME, "Nombre"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_POSITION, "Puesto"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_ORGANIZATION, "Organización"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_DEPARTMENT, "Departamento"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_EMAIL, "Correo-e"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_PHONE, "Teléfono"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_FAX, "Fax"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_COUNTRY, "Pais"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_PROVINCE, "Province"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_CITY, "Ciudad"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_POSTALCODE, "Código postal"); texts.put(AdvancedSearchContactBean.MESSAGE_CONTACT_ADDRESS, "Dirección"); final AdvancedSearchContactCSVServlet instance = new AdvancedSearchContactCSVServlet(); final String content = instance.generateCSVBody(contactPositions, texts); if (!content.equals(CSV_CONTENT)) { fail("\n\nThe result must be:\n\n>>>" + CSV_CONTENT + "<<<\n\ninstead of:\n\n>>>" + content + "<<<"); } }
protected String generateCSVBody (final List<ContactPosition> contactPositions, final Map<String, String> texts) { final StringBuilder body = new StringBuilder(); body.append(this.generateCSVHeader(texts)); for (ContactPosition contactPosition: contactPositions) { if (contactPosition.isActive()) { body.append(this.generateCSVItem(contactPosition)); } } return body.toString(); }
AdvancedSearchContactCSVServlet extends HttpServlet { protected String generateCSVBody (final List<ContactPosition> contactPositions, final Map<String, String> texts) { final StringBuilder body = new StringBuilder(); body.append(this.generateCSVHeader(texts)); for (ContactPosition contactPosition: contactPositions) { if (contactPosition.isActive()) { body.append(this.generateCSVItem(contactPosition)); } } return body.toString(); } }
AdvancedSearchContactCSVServlet extends HttpServlet { protected String generateCSVBody (final List<ContactPosition> contactPositions, final Map<String, String> texts) { final StringBuilder body = new StringBuilder(); body.append(this.generateCSVHeader(texts)); for (ContactPosition contactPosition: contactPositions) { if (contactPosition.isActive()) { body.append(this.generateCSVItem(contactPosition)); } } return body.toString(); }  }
AdvancedSearchContactCSVServlet extends HttpServlet { protected String generateCSVBody (final List<ContactPosition> contactPositions, final Map<String, String> texts) { final StringBuilder body = new StringBuilder(); body.append(this.generateCSVHeader(texts)); for (ContactPosition contactPosition: contactPositions) { if (contactPosition.isActive()) { body.append(this.generateCSVItem(contactPosition)); } } return body.toString(); }   }
AdvancedSearchContactCSVServlet extends HttpServlet { protected String generateCSVBody (final List<ContactPosition> contactPositions, final Map<String, String> texts) { final StringBuilder body = new StringBuilder(); body.append(this.generateCSVHeader(texts)); for (ContactPosition contactPosition: contactPositions) { if (contactPosition.isActive()) { body.append(this.generateCSVItem(contactPosition)); } } return body.toString(); }    }