package cn.sunner.sms2calendar;

import org.junit.Test;

import java.util.Calendar;
import java.util.GregorianCalendar;

import static org.junit.Assert.*;

/**
 * Created by Sunner on 7/16/16.
 */
public class N12306ParserTest {

    @Test
    public void testOneSeat() throws Exception {
        SMSParser parser = new N12306Parser("订单EC11541789,孙先生您已购1月24日D2245次14车13F号南京南19:11开。【铁路客服】");
        assertTrue(parser.isValid());
        assertEquals("D2245次14车13F号", parser.getTitle());
        assertEquals("南京南", parser.getLocation());
        assertEquals(new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), 1, 24, 19, 11), parser.getBeginTime());
    }

    @Test
    public void testTwoSeatsAndChanged() throws Exception {
        SMSParser parser = new N12306Parser("订单EC71177015,孙先生您已签12月9日D2245次14车12D号、4C号上海虹桥19:11开。【铁路客服】");
        assertTrue(parser.isValid());
        assertEquals("D2245次14车12D号、4C号", parser.getTitle());
        assertEquals("上海虹桥", parser.getLocation());
        assertEquals(new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), 12, 9, 19, 11), parser.getBeginTime());
    }

    @Test
    public void testTwoBeds() throws Exception {
        SMSParser parser = new N12306Parser("订单EC76805753,孙先生您已购2月1日Z176次12车31号下铺、36号上铺杭州9:30开。【铁路客服】");
        assertTrue(parser.isValid());
        assertEquals("Z176次12车31号下铺、36号上铺", parser.getTitle());
        assertEquals("杭州", parser.getLocation());
        assertEquals(new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), 2, 1, 9, 30), parser.getBeginTime());
    }

    @Test
    public void testNotValid() throws Exception {
        SMSParser parser = new N12306Parser("孙志岗的2月4日G7394次8车15B号车票退票成功。流水号2EC84941031001001222209833。【铁路客服】");
        assertFalse(parser.isValid());
    }

}
@@ -505,16 +505,17 @@
 als(%22%E5%8D%97%E4%BA%AC%E5%8D%97
+%E7%AB%99
 %22, parse
@@ -968,16 +968,17 @@
 ls(%22%E4%B8%8A%E6%B5%B7%E8%99%B9%E6%A1%A5
+%E7%AB%99
 %22, parse
@@ -1418,16 +1418,17 @@
 uals(%22%E6%9D%AD%E5%B7%9E
+%E7%AB%99
 %22, parse

Update testcases for 站