Package org.mokai

Examples of org.mokai.Message


    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setDirection(Direction.UNKNOWN);

    handler.insertMessage(conn, message);
  }
View Full Code Here


    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setId(10);
    message.setDirection(Direction.TO_CONNECTIONS);

    handler.updateMessage(conn, message);

    verify(outHandler).updateMessage(any(Connection.class), any(Message.class));
    verify(inHandler, never()).updateMessage(any(Connection.class), any(Message.class));
View Full Code Here

    MessageHandler outHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setId(10);
    message.setDirection(Direction.TO_APPLICATIONS);

    handler.updateMessage(conn, message);

    verify(inHandler).updateMessage(any(Connection.class), any(Message.class));
    verify(outHandler, never()).updateMessage(any(Connection.class), any(Message.class));
View Full Code Here

    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setDirection(Direction.UNKNOWN);

    handler.updateMessage(conn, message);
  }
View Full Code Here

  @Test
  public void testListAllMessages() throws Exception {
    MessageHandler inHandler = mock(MessageHandler.class);
    when(inHandler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));
    MessageHandler outHandler = mock(MessageHandler.class);
    when(outHandler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Collection<Message> message = handler.listMessages(conn, new MessageCriteria());
View Full Code Here

  @Test
  public void testListOutboundMessages() throws Exception {
    MessageHandler outHandler = mock(MessageHandler.class);
    when(outHandler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));
    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);
View Full Code Here

  public void testListInboundMessages() throws Exception {
    MessageHandler outHandler = mock(MessageHandler.class);

    MessageHandler inHandler = mock(MessageHandler.class);
    when(inHandler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Collection<Message> message = handler.listMessages(conn,
View Full Code Here

  }

  @Test
  public void testInsertMessage() throws Exception {

    final Message message = new Message();
    message.setDirection(Direction.TO_CONNECTIONS);
    message.setSource("test");
    message.setStatus(Message.STATUS_CREATED);
    message.setProperty("from", "1111");
    message.setProperty("to", "2222");
    message.setProperty("text", "text");
    message.setProperty("other", "other value");

    ConnectionsSmsHandler handler = new ConnectionsSmsHandler();
    long id = handler.insertMessage(connection, message);

    validateMessage(id, new MessageValidator() {

      @Override
      public void validate(ResultSet rs) throws SQLException {
        Assert.assertEquals(rs.getString("source"), message.getSource());
        Assert.assertEquals(rs.getByte("status"), message.getStatus());
        Assert.assertEquals(rs.getString("smsc_from"), message.getProperty("from", String.class));
        Assert.assertEquals(rs.getString("smsc_to"), message.getProperty("to", String.class));
        Assert.assertEquals(rs.getString("smsc_text"), message.getProperty("text", String.class));
        try {
          Assert.assertEquals(rs.getString("other"), new JSONObject().put("other", "other value").toString());
        } catch (JSONException e) {
          Assert.fail("shouldn't had to throw exception", e);
        }
View Full Code Here

  @Test
  public void testUpdateMessage() throws Exception {
    long id = generateRecordToUpdate();

    final Message message = new Message();
    message.setId(id);
    message.setStatus(Message.STATUS_RETRYING);
    message.setDestination("test");
    message.setProperty("receiptStatus", "DELIVRD");
    message.setProperty("other", "other value");

    ConnectionsSmsHandler handler = new ConnectionsSmsHandler();
    boolean found = handler.updateMessage(connection, message);

    Assert.assertTrue(found);

    validateMessage(id, new MessageValidator() {

      @Override
      public void validate(ResultSet rs) throws SQLException {
        Assert.assertEquals(rs.getByte("status"), message.getStatus());
        Assert.assertEquals(rs.getString("destination"), message.getDestination());
        Assert.assertEquals(rs.getString("smsc_receiptstatus"), message.getProperty("receiptStatus", String.class));
        Assert.assertNull(rs.getTimestamp("smsc_receipttime"));
        try {
          Assert.assertEquals(rs.getString("other"), new JSONObject().put("other", "other value").toString());
        } catch (JSONException e) {
          Assert.fail("shouldn't had to throw exception", e);
View Full Code Here

  }

  @Test
  public void testUpdateNotFoundMessage() throws Exception {
    final Message message = new Message();
    message.setId(1L);
    message.setStatus(Message.STATUS_RETRYING);
    message.setDestination("test");

    ConnectionsSmsHandler handler = new ConnectionsSmsHandler();
    boolean found = handler.updateMessage(connection, message);

    Assert.assertFalse(found);
View Full Code Here

TOP

Related Classes of org.mokai.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.