@Test public void testAdminReply() { AdminReply adminReply = new AdminReply(null); adminReply.setAssigneeID("1"); assertEquals(Conversation.MESSAGE_TYPE_ASSIGNMENT, adminReply.getMessageType()); try { Conversation.validateAdminReplyRequest(adminReply); } catch (InvalidException e) { fail(); } adminReply = new AdminReply(null); adminReply.setMessageType("comment"); try { Conversation.validateAdminReplyRequest(adminReply); fail(); } catch (InvalidException e) { assertTrue(e.getMessage() .contains("a comment or note reply must have a body")); } adminReply.setBody(" "); try { Conversation.validateAdminReplyRequest(adminReply); fail(); } catch (InvalidException e) { assertTrue(e.getMessage() .contains("a comment or note reply must have a body")); } adminReply.setBody("Once, in flight school, I was laconic"); try { Conversation.validateAdminReplyRequest(adminReply); } catch (InvalidException e) { fail(); } adminReply.setAttachmentUrls(new String[]{"http: try { Conversation.validateAdminReplyRequest(adminReply); } catch (InvalidException e) { fail(); } }
static void validateAdminReplyRequest(AdminReply reply) { validateMessageType(reply); if (reply.getAssigneeID() != null && !"assignment".equals(reply.getMessageType())) { throw new InvalidException("an assignee id can be set only for a message type of assignment"); } if (("note".equals(reply.getMessageType()) || "comment".equals(reply.getMessageType())) && (isNullOrBlank(reply.getBody())) ) { throw new InvalidException("a comment or note reply must have a body"); } }
Conversation extends TypedData { static void validateAdminReplyRequest(AdminReply reply) { validateMessageType(reply); if (reply.getAssigneeID() != null && !"assignment".equals(reply.getMessageType())) { throw new InvalidException("an assignee id can be set only for a message type of assignment"); } if (("note".equals(reply.getMessageType()) || "comment".equals(reply.getMessageType())) && (isNullOrBlank(reply.getBody())) ) { throw new InvalidException("a comment or note reply must have a body"); } } }
Conversation extends TypedData { static void validateAdminReplyRequest(AdminReply reply) { validateMessageType(reply); if (reply.getAssigneeID() != null && !"assignment".equals(reply.getMessageType())) { throw new InvalidException("an assignee id can be set only for a message type of assignment"); } if (("note".equals(reply.getMessageType()) || "comment".equals(reply.getMessageType())) && (isNullOrBlank(reply.getBody())) ) { throw new InvalidException("a comment or note reply must have a body"); } } Conversation(); }
Conversation extends TypedData { static void validateAdminReplyRequest(AdminReply reply) { validateMessageType(reply); if (reply.getAssigneeID() != null && !"assignment".equals(reply.getMessageType())) { throw new InvalidException("an assignee id can be set only for a message type of assignment"); } if (("note".equals(reply.getMessageType()) || "comment".equals(reply.getMessageType())) && (isNullOrBlank(reply.getBody())) ) { throw new InvalidException("a comment or note reply must have a body"); } } Conversation(); static Conversation find(String id); static Conversation find(String id, Map<String, String> params); static ConversationCollection list(); static ConversationCollection list(Map<String, String> params); static Conversation reply(String id, UserReply reply); static Conversation reply(String id, AdminReply reply); static Conversation markAsRead(String id); static UserMessage create(UserMessage message); static ContactMessage create(ContactMessage message); static AdminMessage create(AdminMessage message); static Conversation runAssignmentRules(String id); String getType(); Admin getCurrentAssignee(); Optional<ConversationPart> getFirstConversationPart(); ConversationPart getMostRecentConversationPart(); String getId(); ConversationMessage getConversationMessage(); CustomerFirstReply getCustomerFirstReply(); ConversationRating getConversationRating(); User getUser(); Admin getAssignee(); long getCreatedAt(); long getUpdatedAt(); long getWaitingSince(); long getSnoozedUntil(); ConversationPartCollection getConversationPartCollection(); TagCollection getTagCollection(); boolean getOpen(); boolean getRead(); String getState(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
Conversation extends TypedData { static void validateAdminReplyRequest(AdminReply reply) { validateMessageType(reply); if (reply.getAssigneeID() != null && !"assignment".equals(reply.getMessageType())) { throw new InvalidException("an assignee id can be set only for a message type of assignment"); } if (("note".equals(reply.getMessageType()) || "comment".equals(reply.getMessageType())) && (isNullOrBlank(reply.getBody())) ) { throw new InvalidException("a comment or note reply must have a body"); } } Conversation(); static Conversation find(String id); static Conversation find(String id, Map<String, String> params); static ConversationCollection list(); static ConversationCollection list(Map<String, String> params); static Conversation reply(String id, UserReply reply); static Conversation reply(String id, AdminReply reply); static Conversation markAsRead(String id); static UserMessage create(UserMessage message); static ContactMessage create(ContactMessage message); static AdminMessage create(AdminMessage message); static Conversation runAssignmentRules(String id); String getType(); Admin getCurrentAssignee(); Optional<ConversationPart> getFirstConversationPart(); ConversationPart getMostRecentConversationPart(); String getId(); ConversationMessage getConversationMessage(); CustomerFirstReply getCustomerFirstReply(); ConversationRating getConversationRating(); User getUser(); Admin getAssignee(); long getCreatedAt(); long getUpdatedAt(); long getWaitingSince(); long getSnoozedUntil(); ConversationPartCollection getConversationPartCollection(); TagCollection getTagCollection(); boolean getOpen(); boolean getRead(); String getState(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }