package org.lxp.dailylog.service.impl;

import static org.junit.Assert.assertEquals;

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.lxp.dailylog.config.MemoryDBTest;
import org.lxp.dailylog.model.NavigatorBase;
import org.lxp.dailylog.service.NavigatorService;
import org.lxp.dailylog.util.DateUtil;
import org.lxp.dailylog.web.util.JsonHelper;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@MemoryDBTest
public class NavigatorServiceImplTest {
    @Resource
    private NavigatorService navigatorService;

    @Test
    public void testAddNavigator() {
        NavigatorBase navigator = new NavigatorBase();
        navigator.setName("333");
        navigator.setTitle("3333");
        navigator.setUrl("http://33.com");
        navigator.setCreatetime(DateUtil.now());
        navigator = navigatorService.addNavigator(navigator);
        assertEquals(
                "{\"seqid\":2,\"name\":\"333\",\"url\":\"http://33.com\",\"title\":\"3333\",\"createtime\":1529683200000}",
                JsonHelper.toString(navigator));
    }

    @Test
    public void testQueryOneByLike() {
        NavigatorBase navigator = navigatorService.queryOneByLike("222");
        assertEquals(
                "{\"seqid\":1,\"name\":\"222\",\"url\":\"http://22.com\",\"title\":\"2222\",\"createtime\":1527609600000}",
                JsonHelper.toString(navigator));
    }
}
@@ -79,16 +79,101 @@
 quals;%0A%0A
+import java.time.LocalDateTime;%0Aimport java.time.ZoneOffset;%0Aimport java.util.Date;%0A%0A
 import j
@@ -399,47 +399,8 @@
 ce;%0A
-import org.lxp.dailylog.util.DateUtil;%0A
 impo
@@ -924,17 +924,79 @@
 Date
-Util.now(
+.from(LocalDateTime.of(2018, 06, 24, 0, 0, 0).toInstant(ZoneOffset.UTC)
 ));%0A
@@ -1194,12 +1194,12 @@
 1529
-6832
+7696
 0000

fix unit test failure