package org.teleal.cling.test.support.messagebox;

import org.teleal.cling.support.messagebox.model.DateTime;
import org.teleal.cling.support.messagebox.model.MessageIncomingCall;
import org.teleal.cling.support.messagebox.model.MessageSMS;
import org.teleal.cling.support.messagebox.model.MessageScheduleReminder;
import org.teleal.cling.support.messagebox.model.NumberName;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

/**
 * @author Christian Bauer
 */
public class MessageBoxTest {

    private final String MESSAGE_SMS =
            "<Category>SMS</Category>" +
                    "<DisplayType>Maximum</DisplayType>" +
                    "<ReceiveTime><Date>2010-06-21</Date><Time>16:34:12</Time></ReceiveTime>" +
                    "<Receiver><Number>1234</Number><Name>foo</Name></Receiver>" +
                    "<Sender><Number>5678</Number><Name>bar</Name></Sender>" +
                    "<Body>Hello World!</Body>";

    private final String MESSAGE_INCOMING_CALL =
            "<Category>Incoming Call</Category>" +
                    "<DisplayType>Maximum</DisplayType>" +
                    "<CallTime><Date>2010-06-21</Date><Time>16:34:12</Time></CallTime>" +
                    "<Callee><Number>1234</Number><Name>foo</Name></Callee>" +
                    "<Caller><Number>5678</Number><Name>bar</Name></Caller>";

    private final String MESSAGE_SCHEDULE_REMINDER =
            "<Category>Schedule Reminder</Category>" +
                    "<DisplayType>Maximum</DisplayType>" +
                    "<StartTime><Date>2010-06-21</Date><Time>16:34:12</Time></StartTime>" +
                    "<Owner><Number>1234</Number><Name>foo</Name></Owner>" +
                    "<Subject>bar</Subject>" +
                    "<EndTime><Date>2010-06-21</Date><Time>17:34:12</Time></EndTime>" +
                    "<Location>baz</Location>" +
                    "<Body>Hello World!</Body>";

    @Test
    public void createSMS() {
        MessageSMS msg = new MessageSMS(
                new DateTime("2010-06-21", "16:34:12"),
                new NumberName("1234", "foo"),
                new NumberName("5678", "bar"),
                "Hello World!"
        );

        String output = msg.toString();
        assertEquals(output, MESSAGE_SMS);

    }

    @Test
    public void createIncomingCall() {
        MessageIncomingCall msg = new MessageIncomingCall(
                new DateTime("2010-06-21", "16:34:12"),
                new NumberName("1234", "foo"),
                new NumberName("5678", "bar")
        );

        String output = msg.toString();
        assertEquals(output, MESSAGE_INCOMING_CALL);

    }

    @Test
    public void createScheduleReminder() {
        MessageScheduleReminder msg = new MessageScheduleReminder(
                new DateTime("2010-06-21", "16:34:12"),
                new NumberName("1234", "foo"),
                "bar",
                new DateTime("2010-06-21", "17:34:12"),
                "baz",
                "Hello World!"
        );

        String output = msg.toString();
        assertEquals(output, MESSAGE_SCHEDULE_REMINDER);

    }

}
