/** Tests that the author name is properly escaped and set. */ public void testAuthor() { assertEquals("Author", comment.getAuthor()); // blank or null author name defaults to "Anonymous" comment.setAuthor(""); assertEquals("Anonymous", comment.getAuthor()); comment.setAuthor(null); assertEquals("Anonymous", comment.getAuthor()); // for security, special HTML characters aren't removed // (they are rendered out at runtime) comment.setAuthor("<Author>"); assertEquals("<Author>", comment.getAuthor()); }
/** Tests that a comment can be cloned. */ public void testClone() { Comment clonedComment = (Comment) comment.clone(); assertEquals(comment.getTitle(), clonedComment.getTitle()); assertEquals(comment.getBody(), clonedComment.getBody()); assertEquals(comment.getWebsite(), clonedComment.getWebsite()); assertEquals(comment.getAvatar(), clonedComment.getAvatar()); assertEquals(comment.getAuthor(), clonedComment.getAuthor()); assertEquals(comment.getIpAddress(), clonedComment.getIpAddress()); assertEquals(comment.getDate(), clonedComment.getDate()); assertEquals(comment.getId(), clonedComment.getId()); assertEquals(comment.getState(), clonedComment.getState()); assertEquals(comment.getParent(), clonedComment.getParent()); assertEquals(comment.getBlogEntry(), clonedComment.getBlogEntry()); }
/** * Insert data. * * @param comment the comment * @return the number of inserted */ public long insertComment(Comment comment) { this.insertComment.bindString(1, comment.getChatterId()); this.insertComment.bindString(2, comment.getCommentId()); this.insertComment.bindString(3, comment.getAuthor()); this.insertComment.bindString(4, comment.getBody()); return this.insertComment.executeInsert(); }
/** * Delete a comment from a song. * * @param authorId The author of the song. */ public void deleteComment(String authorId, Date date) { for (Comment comment : comments) { if (comment.getAuthor().equals(authorId) && comment.getDate().equals(date)) { comments.remove(comment); return; } } }
public MessageDetail getMessage() { // 现在pub_message接口返回的是comment对象。所以要转成message message = new MessageDetail(); if (comment != null) { message.setId(comment.getId()); message.setPortrait(comment.getPortrait()); message.setAuthor(comment.getAuthor()); message.setAuthorId(comment.getId()); message.setContent(comment.getContent()); message.setPubDate(comment.getPubDate()); } return message; }
/** Test that a Comment instance can be created correctly. */ public void testConstructionOfSimpleInstance() { assertNotNull(comment); assertEquals("Title", comment.getTitle()); assertEquals("Body", comment.getBody()); assertEquals("Author", comment.getAuthor()); assertEquals("*****@*****.**", comment.getEmail()); assertEquals("http://www.google.com", comment.getWebsite()); assertEquals("http://graph.facebook.com/user/picture", comment.getAvatar()); assertEquals("127.0.0.1", comment.getIpAddress()); assertNotNull(comment.getDate()); assertEquals(comment.getDate().getTime(), comment.getId()); assertNotNull(comment.getBlogEntry()); assertEquals(State.APPROVED, comment.getState()); assertEquals("c/" + comment.getBlogEntry().getId() + "/" + comment.getId(), comment.getGuid()); }
public synchronized boolean send() { Boolean complete_send_to_crm = true; SimpleDateFormat format = new SimpleDateFormat(); format.applyPattern("dd/MM/yyyy HH:mm:ss"); try { BasicXmlData xml = new BasicXmlData("action"); xml.setAttribute("name", "Comment"); BasicXmlData xml_level_1 = new BasicXmlData("parameters"); BasicXmlData xml_level_2_id_trouble = new BasicXmlData("parameter"); xml_level_2_id_trouble.setAttribute("name", "id_trouble"); xml_level_2_id_trouble.setAttribute("value", String.valueOf(trouble.getId())); xml_level_1.addKid(xml_level_2_id_trouble); BasicXmlData xml_level_2_id_comment = new BasicXmlData("parameter"); xml_level_2_id_comment.setAttribute("name", "id_comment"); xml_level_2_id_comment.setAttribute("value", String.valueOf(comment.getId())); xml_level_1.addKid(xml_level_2_id_comment); BasicXmlData xml_level_2_author = new BasicXmlData("parameter"); xml_level_2_author.setAttribute("name", "author"); xml_level_2_author.setAttribute("value", comment.getAuthor().getFio()); xml_level_1.addKid(xml_level_2_author); BasicXmlData xml_level_2_desc = new BasicXmlData("parameter"); xml_level_2_desc.setAttribute("name", "content"); xml_level_2_desc.setAttribute("value", comment.getText()); xml_level_1.addKid(xml_level_2_desc); BasicXmlData xml_level_2_date = new BasicXmlData("parameter"); xml_level_2_date.setAttribute("name", "date"); xml_level_2_date.setAttribute( "value", format.format(new Date(Long.valueOf(comment.getTime())))); xml_level_1.addKid(xml_level_2_date); xml.addKid(xml_level_1); ByteArrayOutputStream baos = new ByteArrayOutputStream(); xml.save(baos); SendToCrm.send(baos); } catch (Exception e) { log.error( "Comment [" + comment.getId() + "] to trouble " + trouble.getTitle() + " [" + trouble.getId() + "] is not sent to CRM - " + e.getMessage()); e.printStackTrace(); complete_send_to_crm = false; } if (complete_send_to_crm) { log.info( "Comment [" + trouble.getId() + "] to trouble " + trouble.getTitle() + " [" + trouble.getId() + "] successfully submitted to CRM successfully."); } return complete_send_to_crm; }
protected SCell importCell(Cell poiCell, int row, SSheet sheet) { SCell cell = sheet.getCell(row, poiCell.getColumnIndex()); cell.setCellStyle(importCellStyle(poiCell.getCellStyle())); switch (poiCell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: cell.setNumberValue(poiCell.getNumericCellValue()); break; case Cell.CELL_TYPE_STRING: RichTextString poiRichTextString = poiCell.getRichStringCellValue(); if (poiRichTextString != null && poiRichTextString.numFormattingRuns() > 0) { SRichText richText = cell.setupRichTextValue(); importRichText(poiCell, poiRichTextString, richText); } else { cell.setStringValue(poiCell.getStringCellValue()); } break; case Cell.CELL_TYPE_BOOLEAN: cell.setBooleanValue(poiCell.getBooleanCellValue()); break; case Cell.CELL_TYPE_FORMULA: cell.setFormulaValue(poiCell.getCellFormula()); // ZSS-873 if (isImportCache() && !poiCell.isCalcOnLoad() && !mustCalc(cell)) { ValueEval val = null; switch (poiCell.getCachedFormulaResultType()) { case Cell.CELL_TYPE_NUMERIC: val = new NumberEval(poiCell.getNumericCellValue()); break; case Cell.CELL_TYPE_STRING: RichTextString poiRichTextString0 = poiCell.getRichStringCellValue(); if (poiRichTextString0 != null && poiRichTextString0.numFormattingRuns() > 0) { SRichText richText = new RichTextImpl(); importRichText(poiCell, poiRichTextString0, richText); val = new StringEval(richText.getText()); } else { val = new StringEval(poiCell.getStringCellValue()); } break; case Cell.CELL_TYPE_BOOLEAN: val = BoolEval.valueOf(poiCell.getBooleanCellValue()); break; case Cell.CELL_TYPE_ERROR: val = ErrorEval.valueOf(poiCell.getErrorCellValue()); break; case Cell.CELL_TYPE_BLANK: default: // do nothing } if (val != null) { ((AbstractCellAdv) cell).setFormulaResultValue(val); } } break; case Cell.CELL_TYPE_ERROR: cell.setErrorValue(PoiEnumConversion.toErrorCode(poiCell.getErrorCellValue())); break; case Cell.CELL_TYPE_BLANK: // do nothing because spreadsheet model auto creates blank cells default: // TODO log: leave an unknown cell type as a blank cell. break; } Hyperlink poiHyperlink = poiCell.getHyperlink(); if (poiHyperlink != null) { String addr = poiHyperlink.getAddress(); String label = poiHyperlink.getLabel(); SHyperlink hyperlink = cell.setupHyperlink( PoiEnumConversion.toHyperlinkType(poiHyperlink.getType()), addr == null ? "" : addr, label == null ? "" : label); cell.setHyperlink(hyperlink); } Comment poiComment = poiCell.getCellComment(); if (poiComment != null) { SComment comment = cell.setupComment(); comment.setAuthor(poiComment.getAuthor()); comment.setVisible(poiComment.isVisible()); RichTextString poiRichTextString = poiComment.getString(); if (poiRichTextString != null && poiRichTextString.numFormattingRuns() > 0) { importRichText(poiCell, poiComment.getString(), comment.setupRichText()); } else { comment.setText(poiComment.toString()); } } return cell; }