commit a2983552bdf355f1d4c31a5eaa801f0fcab82359
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Tue Aug 21 15:07:49 2018 +0700

    UPDATE Proc

diff --git a/Procfile b/Procfile
index eb75169..9f730d3 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: ./gradlew bootRun -Dserver.port=$PORT
+web: java $JAVA_OPTS -jar target/*.jar --server.port=$PORT
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index ffc713e..0ef90b1 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -13,16 +13,16 @@ line:
   bot:
     channelToken: 8G/19OV1PFe3LtbbUIK1YhzQBtigpfk2ncxGA+Ul3yzDhRKEl2O6rJUj/RmMMe93lojH6foXpZ5Ruw6CpN6+/klIWoQT3dIGI3iMl6aYvd8qYjcpSMpC4/WsYi6OaSUhf+UADvVyOBdHvIPpN8dL5QdB04t89/1O/w1cDnyilFU=
     channelSecret: 52f1f89f193bd08fa092371e9865afc8
 ---
 spring:
-  profiles: default
+  profiles: prod
   devtools:
     restart:
       enabled: true
       additional-paths: src
   data:
       mongodb:
         host: ds125352.mlab.com:25352
         database: todoexam
         username: todo_app
         password: ToDo@pp1

commit 0066b302b16f6610a39db6a14b7665c2efed825d
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Tue Aug 21 14:53:34 2018 +0700

    UPDATE Proc

diff --git a/Procfile b/Procfile
index c0b806a..eb75169 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: ./gradlew bootRun --server.port=$PORT --spring.profiles.active=prod
+web: ./gradlew bootRun -Dserver.port=$PORT

commit 96f52bd664fcdc8b29f77d5587b867762b63134a
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Tue Aug 21 14:31:20 2018 +0700

    UPDATE Proc

diff --git a/Procfile b/Procfile
index 5d8e02b..c0b806a 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: java $JAVA_OPTS -jar target/*.jar --server.port=$PORT --spring.profiles.active=prod
\ No newline at end of file
+web: ./gradlew bootRun --server.port=$PORT --spring.profiles.active=prod

commit 4c653db2a3e97c9e53ca898c3ba4a724eedc8d88
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Tue Aug 21 14:19:37 2018 +0700

    UPDATE config for heroku

diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 0ef90b1..ffc713e 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -13,16 +13,16 @@ line:
   bot:
     channelToken: 8G/19OV1PFe3LtbbUIK1YhzQBtigpfk2ncxGA+Ul3yzDhRKEl2O6rJUj/RmMMe93lojH6foXpZ5Ruw6CpN6+/klIWoQT3dIGI3iMl6aYvd8qYjcpSMpC4/WsYi6OaSUhf+UADvVyOBdHvIPpN8dL5QdB04t89/1O/w1cDnyilFU=
     channelSecret: 52f1f89f193bd08fa092371e9865afc8
 ---
 spring:
-  profiles: prod
+  profiles: default
   devtools:
     restart:
       enabled: true
       additional-paths: src
   data:
       mongodb:
         host: ds125352.mlab.com:25352
         database: todoexam
         username: todo_app
         password: ToDo@pp1

commit 2d35049c07e2b61b1d84b4726c8d1e3c66e4e3b3
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Tue Aug 21 14:15:53 2018 +0700

    ADD Procfile

diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..5d8e02b
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: java $JAVA_OPTS -jar target/*.jar --server.port=$PORT --spring.profiles.active=prod
\ No newline at end of file

commit 41b5bc70ca224988fbfdc179f878b42ec7f73237
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Tue Aug 21 13:44:37 2018 +0700

    ADD line auth and config prod

diff --git a/build.gradle b/build.gradle
index 19a25b8..a3211dd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,2 +19,3 @@ apply plugin: 'io.spring.dependency-management'
 sourceCompatibility = 1.8
+bootRun.systemProperties = System.properties
 
@@ -26,14 +27,15 @@ repositories {
 dependencies {
     compile("org.springframework.boot:spring-boot-starter-web")
     compile("org.springframework.boot:spring-boot-devtools")
     compile("org.springframework.boot:spring-boot-starter-actuator")
     compile("org.springframework.boot:spring-boot-starter-data-mongodb")
     compile('org.valid4j:valid4j:0.5.0')
     compile('joda-time:joda-time:2.9.9')
     compile 'com.linecorp.bot:line-bot-spring-boot:2.0.0'
     compile("org.projectlombok:lombok:1.18.2")
+    compile("com.mashape.unirest:unirest-java:1.4.9")
 
     testCompile("de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.0.0")
     testCompile("org.springframework.boot:spring-boot-starter-test")
     testCompile group: 'junit', name: 'junit', version: '4.12'
 }
diff --git a/settings.gradle b/settings.gradle
index 381292b..b41c0d1 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,2 +1,2 @@
-rootProject.name = 'line-exam'
+rootProject.name = 'todoapp'
 
diff --git a/src/main/java/com/wanichnun/lineexam/Application.java b/src/main/java/com/wanichnun/todoapp/Application.java
similarity index 92%
rename from src/main/java/com/wanichnun/lineexam/Application.java
rename to src/main/java/com/wanichnun/todoapp/Application.java
index b9f1ac0..42ee9a8 100644
--- a/src/main/java/com/wanichnun/lineexam/Application.java
+++ b/src/main/java/com/wanichnun/todoapp/Application.java
@@ -1,2 +1,2 @@
-package com.wanichnun.lineexam;
+package com.wanichnun.todoapp;
 
diff --git a/src/main/java/com/wanichnun/todoapp/config/RestTemplateConfig.java b/src/main/java/com/wanichnun/todoapp/config/RestTemplateConfig.java
new file mode 100644
index 0000000..5766f95
--- /dev/null
+++ b/src/main/java/com/wanichnun/todoapp/config/RestTemplateConfig.java
@@ -0,0 +1,13 @@
+package com.wanichnun.todoapp.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+@Configuration
+public class RestTemplateConfig {
+	@Bean
+	public RestTemplate restTemplate() {
+		return new RestTemplate();
+	}
+}
diff --git a/src/main/java/com/wanichnun/todoapp/controller/AuthController.java b/src/main/java/com/wanichnun/todoapp/controller/AuthController.java
new file mode 100644
index 0000000..caad3c2
--- /dev/null
+++ b/src/main/java/com/wanichnun/todoapp/controller/AuthController.java
@@ -0,0 +1,25 @@
+package com.wanichnun.todoapp.controller;
+
+import com.mashape.unirest.http.exceptions.UnirestException;
+import com.wanichnun.todoapp.model.AuthRequest;
+import com.wanichnun.todoapp.model.Response;
+import com.wanichnun.todoapp.model.ResponseModel;
+import com.wanichnun.todoapp.service.AuthService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping(path = "/api/v1/auth")
+public class AuthController {
+    @Autowired
+    private AuthService authService;
+
+    @PostMapping()
+    public HttpEntity<ResponseModel> update(
+            @RequestBody AuthRequest request
+            ) throws UnirestException {
+        return new ResponseModel(Response.SUCCESS.getContent(), authService.getAccessToken(request)).build(HttpStatus.OK);
+    }
+}
diff --git a/src/main/java/com/wanichnun/lineexam/controller/TodoController.java b/src/main/java/com/wanichnun/todoapp/controller/TodoController.java
similarity index 82%
rename from src/main/java/com/wanichnun/lineexam/controller/TodoController.java
rename to src/main/java/com/wanichnun/todoapp/controller/TodoController.java
index 9f4a26f..988a5e4 100644
--- a/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
+++ b/src/main/java/com/wanichnun/todoapp/controller/TodoController.java
@@ -1,7 +1,7 @@
-package com.wanichnun.lineexam.controller;
+package com.wanichnun.todoapp.controller;
 
-import com.wanichnun.lineexam.model.Response;
-import com.wanichnun.lineexam.model.ResponseModel;
-import com.wanichnun.lineexam.model.TodoUpdateRequest;
-import com.wanichnun.lineexam.service.TodoService;
+import com.wanichnun.todoapp.model.Response;
+import com.wanichnun.todoapp.model.ResponseModel;
+import com.wanichnun.todoapp.model.TodoUpdateRequest;
+import com.wanichnun.todoapp.service.TodoService;
 import org.springframework.beans.factory.annotation.Autowired;
diff --git a/src/main/java/com/wanichnun/lineexam/document/Todo.java b/src/main/java/com/wanichnun/todoapp/document/Todo.java
similarity index 90%
rename from src/main/java/com/wanichnun/lineexam/document/Todo.java
rename to src/main/java/com/wanichnun/todoapp/document/Todo.java
index 0249863..9a5df1b 100644
--- a/src/main/java/com/wanichnun/lineexam/document/Todo.java
+++ b/src/main/java/com/wanichnun/todoapp/document/Todo.java
@@ -1,2 +1,2 @@
-package com.wanichnun.lineexam.document;
+package com.wanichnun.todoapp.document;
 
diff --git a/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java b/src/main/java/com/wanichnun/todoapp/handler/MessageHandler.java
similarity index 82%
rename from src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java
rename to src/main/java/com/wanichnun/todoapp/handler/MessageHandler.java
index 5ae46ba..5882470 100644
--- a/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java
+++ b/src/main/java/com/wanichnun/todoapp/handler/MessageHandler.java
@@ -1,2 +1,2 @@
-package com.wanichnun.lineexam.handler;
+package com.wanichnun.todoapp.handler;
 
@@ -7,5 +7,3 @@ import com.linecorp.bot.spring.boot.annotation.EventMapping;
 import com.linecorp.bot.spring.boot.annotation.LineMessageHandler;
-import com.sun.org.apache.xpath.internal.operations.Bool;
-import com.wanichnun.lineexam.document.Todo;
-import com.wanichnun.lineexam.service.TodoService;
+import com.wanichnun.todoapp.service.TodoService;
 import lombok.extern.slf4j.Slf4j;
@@ -14,7 +12,3 @@ import org.valid4j.errors.RequireViolation;
 
-import java.text.DateFormat;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
 
diff --git a/src/main/java/com/wanichnun/todoapp/model/AuthRequest.java b/src/main/java/com/wanichnun/todoapp/model/AuthRequest.java
new file mode 100644
index 0000000..fb8d4f1
--- /dev/null
+++ b/src/main/java/com/wanichnun/todoapp/model/AuthRequest.java
@@ -0,0 +1,8 @@
+package com.wanichnun.todoapp.model;
+
+import lombok.Data;
+
+@Data
+public class AuthRequest {
+    private String code;
+}
diff --git a/src/main/java/com/wanichnun/todoapp/model/AuthResponse.java b/src/main/java/com/wanichnun/todoapp/model/AuthResponse.java
new file mode 100644
index 0000000..61c780d
--- /dev/null
+++ b/src/main/java/com/wanichnun/todoapp/model/AuthResponse.java
@@ -0,0 +1,21 @@
+package com.wanichnun.todoapp.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+@Data
+public class AuthResponse {
+    private String scope;
+
+    @JsonProperty(value = "access_token")
+    private String accessToken;
+
+    @JsonProperty(value = "token_type")
+    private String tokenType;
+
+    @JsonProperty(value = "expires_in")
+    private Integer expiresIn;
+
+    @JsonProperty(value = "refresh_token")
+    private String refreshToken;
+}
diff --git a/src/main/java/com/wanichnun/lineexam/model/Response.java b/src/main/java/com/wanichnun/todoapp/model/Response.java
similarity index 84%
rename from src/main/java/com/wanichnun/lineexam/model/Response.java
rename to src/main/java/com/wanichnun/todoapp/model/Response.java
index 339c0d4..ac10477 100644
--- a/src/main/java/com/wanichnun/lineexam/model/Response.java
+++ b/src/main/java/com/wanichnun/todoapp/model/Response.java
@@ -1,2 +1,2 @@
-package com.wanichnun.lineexam.model;
+package com.wanichnun.todoapp.model;
 
diff --git a/src/main/java/com/wanichnun/lineexam/model/ResponseModel.java b/src/main/java/com/wanichnun/todoapp/model/ResponseModel.java
similarity index 94%
rename from src/main/java/com/wanichnun/lineexam/model/ResponseModel.java
rename to src/main/java/com/wanichnun/todoapp/model/ResponseModel.java
index 67ca7f2..fbfff7a 100644
--- a/src/main/java/com/wanichnun/lineexam/model/ResponseModel.java
+++ b/src/main/java/com/wanichnun/todoapp/model/ResponseModel.java
@@ -1,2 +1,2 @@
-package com.wanichnun.lineexam.model;
+package com.wanichnun.todoapp.model;
 
diff --git a/src/main/java/com/wanichnun/lineexam/model/TodoUpdateRequest.java b/src/main/java/com/wanichnun/todoapp/model/TodoUpdateRequest.java
similarity index 79%
rename from src/main/java/com/wanichnun/lineexam/model/TodoUpdateRequest.java
rename to src/main/java/com/wanichnun/todoapp/model/TodoUpdateRequest.java
index cdfd740..889e4b5 100644
--- a/src/main/java/com/wanichnun/lineexam/model/TodoUpdateRequest.java
+++ b/src/main/java/com/wanichnun/todoapp/model/TodoUpdateRequest.java
@@ -1,2 +1,2 @@
-package com.wanichnun.lineexam.model;
+package com.wanichnun.todoapp.model;
 
diff --git a/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java b/src/main/java/com/wanichnun/todoapp/repository/TodoRepository.java
similarity index 77%
rename from src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
rename to src/main/java/com/wanichnun/todoapp/repository/TodoRepository.java
index 19f73d6..23d092b 100644
--- a/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
+++ b/src/main/java/com/wanichnun/todoapp/repository/TodoRepository.java
@@ -1,4 +1,4 @@
-package com.wanichnun.lineexam.repository;
+package com.wanichnun.todoapp.repository;
 
-import com.wanichnun.lineexam.document.Todo;
+import com.wanichnun.todoapp.document.Todo;
 import org.springframework.data.mongodb.repository.MongoRepository;
diff --git a/src/main/java/com/wanichnun/todoapp/service/AuthService.java b/src/main/java/com/wanichnun/todoapp/service/AuthService.java
new file mode 100644
index 0000000..f93775c
--- /dev/null
+++ b/src/main/java/com/wanichnun/todoapp/service/AuthService.java
@@ -0,0 +1,53 @@
+package com.wanichnun.todoapp.service;
+
+import com.wanichnun.todoapp.model.AuthRequest;
+import com.wanichnun.todoapp.model.AuthResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.RestTemplate;
+
+@Slf4j
+@Service
+public class AuthService {
+    @Autowired
+    private RestTemplate restTemplate;
+
+    public AuthResponse getAccessToken(AuthRequest request) {
+        String getAccessTokenUrl = "https://api.line.me/v2/oauth/accessToken";
+
+        String clientId = "1601887173";
+        String clientSecret = "9df37fe9ad6c3c6ba0d6146be02489d5";
+        String grantType = "authorization_code";
+        String redirectUri = "https://todo-d976c.firebaseapp.com/callback";
+
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+
+        MultiValueMap<String, String> map= new LinkedMultiValueMap<>();
+        map.add("code", request.getCode());
+        map.add("client_id", clientId);
+        map.add("client_secret", clientSecret);
+        map.add("grant_type", grantType);
+        map.add("redirect_uri", redirectUri);
+
+        HttpEntity<MultiValueMap<String, String>> requestForm = new HttpEntity<>(map, headers);
+
+        ResponseEntity<AuthResponse> response = null;
+        try {
+            response = restTemplate.postForEntity(getAccessTokenUrl, requestForm , AuthResponse.class);
+        } catch (HttpClientErrorException e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+
+        return response.getBody();
+    }
+}
diff --git a/src/main/java/com/wanichnun/lineexam/service/TodoService.java b/src/main/java/com/wanichnun/todoapp/service/TodoService.java
similarity index 89%
rename from src/main/java/com/wanichnun/lineexam/service/TodoService.java
rename to src/main/java/com/wanichnun/todoapp/service/TodoService.java
index 2ccd8c0..e314712 100644
--- a/src/main/java/com/wanichnun/lineexam/service/TodoService.java
+++ b/src/main/java/com/wanichnun/todoapp/service/TodoService.java
@@ -1,11 +1,8 @@
-package com.wanichnun.lineexam.service;
+package com.wanichnun.todoapp.service;
 
 import com.linecorp.bot.model.message.TextMessage;
-import com.sun.org.apache.xpath.internal.operations.Bool;
-import com.wanichnun.lineexam.document.Todo;
-import com.wanichnun.lineexam.model.ResponseModel;
-import com.wanichnun.lineexam.repository.TodoRepository;
+import com.wanichnun.todoapp.document.Todo;
+import com.wanichnun.todoapp.repository.TodoRepository;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
 import org.springframework.stereotype.Service;
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 95bb834..0ef90b1 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,14 +1,33 @@
+spring:
+  profiles: dev
+  devtools:
+    restart:
+      enabled: true
+      additional-paths: src
+  data:
+      mongodb:
+        host: localhost
+        database: todo
+
 line:
   bot:
     channelToken: 8G/19OV1PFe3LtbbUIK1YhzQBtigpfk2ncxGA+Ul3yzDhRKEl2O6rJUj/RmMMe93lojH6foXpZ5Ruw6CpN6+/klIWoQT3dIGI3iMl6aYvd8qYjcpSMpC4/WsYi6OaSUhf+UADvVyOBdHvIPpN8dL5QdB04t89/1O/w1cDnyilFU=
     channelSecret: 52f1f89f193bd08fa092371e9865afc8
-
+---
 spring:
+  profiles: prod
   devtools:
     restart:
       enabled: true
       additional-paths: src
   data:
       mongodb:
-        host: localhost
-        database: todo
\ No newline at end of file
+        host: ds125352.mlab.com:25352
+        database: todoexam
+        username: todo_app
+        password: ToDo@pp1
+
+line:
+  bot:
+    channelToken: 8G/19OV1PFe3LtbbUIK1YhzQBtigpfk2ncxGA+Ul3yzDhRKEl2O6rJUj/RmMMe93lojH6foXpZ5Ruw6CpN6+/klIWoQT3dIGI3iMl6aYvd8qYjcpSMpC4/WsYi6OaSUhf+UADvVyOBdHvIPpN8dL5QdB04t89/1O/w1cDnyilFU=
+    channelSecret: 52f1f89f193bd08fa092371e9865afc8
\ No newline at end of file
diff --git a/src/test/java/com/wanichnun/lineexam/handler/MessageHandlerTest.java b/src/test/java/com/wanichnun/todoapp/handler/MessageHandlerTest.java
similarity index 77%
rename from src/test/java/com/wanichnun/lineexam/handler/MessageHandlerTest.java
rename to src/test/java/com/wanichnun/todoapp/handler/MessageHandlerTest.java
index afadfe1..9f80a4b 100644
--- a/src/test/java/com/wanichnun/lineexam/handler/MessageHandlerTest.java
+++ b/src/test/java/com/wanichnun/todoapp/handler/MessageHandlerTest.java
@@ -1,5 +1,3 @@
-package com.wanichnun.lineexam.handler;
+package com.wanichnun.todoapp.handler;
 
-import com.linecorp.bot.model.event.message.TextMessageContent;
-import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java b/src/test/java/com/wanichnun/todoapp/service/TodoServiceTest.java
similarity index 97%
rename from src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
rename to src/test/java/com/wanichnun/todoapp/service/TodoServiceTest.java
index aa86948..60c7777 100644
--- a/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
+++ b/src/test/java/com/wanichnun/todoapp/service/TodoServiceTest.java
@@ -1,5 +1,5 @@
-package com.wanichnun.lineexam.service;
+package com.wanichnun.todoapp.service;
 
-import com.wanichnun.lineexam.document.Todo;
-import com.wanichnun.lineexam.repository.TodoRepository;
+import com.wanichnun.todoapp.document.Todo;
+import com.wanichnun.todoapp.repository.TodoRepository;
 import org.junit.Assert;

commit 4b54016433be28750fceec91b8f4187eb76880bf
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Mon Aug 20 17:30:10 2018 +0700

    FIX issue document id

diff --git a/src/main/java/com/wanichnun/lineexam/controller/TodoController.java b/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
index 85ef59a..9f4a26f 100644
--- a/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
+++ b/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
@@ -4,2 +4,3 @@ import com.wanichnun.lineexam.model.Response;
 import com.wanichnun.lineexam.model.ResponseModel;
+import com.wanichnun.lineexam.model.TodoUpdateRequest;
 import com.wanichnun.lineexam.service.TodoService;
@@ -8,19 +9,29 @@ import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 @RestController
-@RequestMapping(path = "/api/v1/todos")
+@RequestMapping(path = "/api/v1/users/{userId}/todos")
 public class TodoController {
     @Autowired
     private TodoService todoService;
 
     @GetMapping
     public HttpEntity<ResponseModel> getAll(
-            @RequestParam(name = "userId") String userId) {
+            @PathVariable(name = "userId") String userId) {
         return new ResponseModel(Response.SUCCESS.getContent(), todoService.listTodos(userId)).build(HttpStatus.OK);
     }
 
+    @PutMapping(path = "{todoId}")
+    public HttpEntity<ResponseModel> update(
+            @PathVariable(name = "userId") String userId,
+            @PathVariable(name = "todoId") String todoId,
+            @RequestBody TodoUpdateRequest request
+    ) {
+        return new ResponseModel(Response.SUCCESS.getContent(), todoService.update(
+                todoId,
+                userId,
+                request.getIsPinned(),
+                request.getIsDone(),
+                request.getOrder())).build(HttpStatus.OK);
+    }
 }
diff --git a/src/main/java/com/wanichnun/lineexam/document/Todo.java b/src/main/java/com/wanichnun/lineexam/document/Todo.java
index c9ebe0b..0249863 100644
--- a/src/main/java/com/wanichnun/lineexam/document/Todo.java
+++ b/src/main/java/com/wanichnun/lineexam/document/Todo.java
@@ -3,5 +3,4 @@ package com.wanichnun.lineexam.document;
 import lombok.Data;
+import org.springframework.data.annotation.Id;
 import org.springframework.data.mongodb.core.mapping.Document;
-import org.springframework.data.mongodb.core.mapping.Field;
-
 import java.util.Date;
@@ -9,12 +8,12 @@ import java.util.Date;
 @Data
 @Document(collection = "Todo")
 public class Todo {
-    @Field(value = "id")
+    @Id
     private String id;
     private String userId;
     private String taskName;
     private Boolean isPinned;
     private Boolean isDone;
     private Long order;
     private Date date;
 }
diff --git a/src/main/java/com/wanichnun/lineexam/model/TodoUpdateRequest.java b/src/main/java/com/wanichnun/lineexam/model/TodoUpdateRequest.java
new file mode 100644
index 0000000..cdfd740
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/model/TodoUpdateRequest.java
@@ -0,0 +1,10 @@
+package com.wanichnun.lineexam.model;
+
+import lombok.Data;
+
+@Data
+public class TodoUpdateRequest {
+    private Boolean isPinned;
+    private Boolean isDone;
+    private Long order;
+}

commit 938c552b64e2d07b100be0b4706d84bd5edbe78c
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Mon Aug 20 17:12:26 2018 +0700

    ADD api list todos

diff --git a/src/main/java/com/wanichnun/lineexam/controller/TodoController.java b/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
index 1dc6d1d..85ef59a 100644
--- a/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
+++ b/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
@@ -2,3 +2,11 @@ package com.wanichnun.lineexam.controller;
 
+import com.wanichnun.lineexam.model.Response;
+import com.wanichnun.lineexam.model.ResponseModel;
+import com.wanichnun.lineexam.service.TodoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -6,5 +14,13 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping(path = "/api/v1/todos")
 public class TodoController {
+    @Autowired
+    private TodoService todoService;
+
+    @GetMapping
+    public HttpEntity<ResponseModel> getAll(
+            @RequestParam(name = "userId") String userId) {
+        return new ResponseModel(Response.SUCCESS.getContent(), todoService.listTodos(userId)).build(HttpStatus.OK);
+    }
 
 }
diff --git a/src/main/java/com/wanichnun/lineexam/model/Response.java b/src/main/java/com/wanichnun/lineexam/model/Response.java
new file mode 100644
index 0000000..339c0d4
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/model/Response.java
@@ -0,0 +1,15 @@
+package com.wanichnun.lineexam.model;
+
+import lombok.Getter;
+
+@Getter
+public enum Response {
+    SUCCESS("success"),
+    ERROR("error");
+
+    private final String content;
+
+    Response(String content) {
+        this.content = content;
+    }
+}
diff --git a/src/main/java/com/wanichnun/lineexam/model/ResponseModel.java b/src/main/java/com/wanichnun/lineexam/model/ResponseModel.java
new file mode 100644
index 0000000..67ca7f2
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/model/ResponseModel.java
@@ -0,0 +1,27 @@
+package com.wanichnun.lineexam.model;
+
+import lombok.Data;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+@Data
+public class ResponseModel {
+
+    final String message;
+    final Object data;
+
+    public ResponseModel(String message, Object data) {
+        this.message = message;
+        this.data = data;
+    }
+
+    public ResponseModel(String message) {
+        this.message = message;
+        this.data = "";
+    }
+
+    public HttpEntity<ResponseModel> build(HttpStatus status) {
+        return new ResponseEntity<>(new ResponseModel(this.message, this.data), status);
+    }
+}
diff --git a/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java b/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
index 54dc943..19f73d6 100644
--- a/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
+++ b/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
@@ -9,3 +9,5 @@ import java.util.Optional;
 public interface TodoRepository extends MongoRepository<Todo, String> {
     Optional<Todo> findByIdAndUserId(String id, String userId);
+
+    List<Todo> findByUserId(String userId);
 }
diff --git a/src/main/java/com/wanichnun/lineexam/service/TodoService.java b/src/main/java/com/wanichnun/lineexam/service/TodoService.java
index 5c1d7da..2ccd8c0 100644
--- a/src/main/java/com/wanichnun/lineexam/service/TodoService.java
+++ b/src/main/java/com/wanichnun/lineexam/service/TodoService.java
@@ -5,2 +5,3 @@ import com.sun.org.apache.xpath.internal.operations.Bool;
 import com.wanichnun.lineexam.document.Todo;
+import com.wanichnun.lineexam.model.ResponseModel;
 import com.wanichnun.lineexam.repository.TodoRepository;
@@ -8,2 +9,3 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
 import org.springframework.stereotype.Service;
@@ -13,6 +15,3 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Optional;
-import java.util.UUID;
+import java.util.*;
 
@@ -21,62 +20,67 @@ import static org.valid4j.Assertive.require;
 @Slf4j
 @Service
 public class TodoService {
 
     private TodoRepository todoRepository;
 
     @Autowired
     public TodoService(TodoRepository todoRepository) {
         this.todoRepository = todoRepository;
     }
 
     public TextMessage handleTodoCreateRequest(String userId, String message) throws ParseException {
         Boolean isPinned = false;
         Boolean isDone = false;
         Long order = 0L;
 
         String[] splittedMessage = message.split(" : ");
         require(splittedMessage.length >= 2 && splittedMessage.length <= 3, "Invalid text format");
 
         String taskName = splittedMessage[0];
         String dateText = splittedMessage[1];
         String timeText = "12:00";
         if (splittedMessage.length > 2) {
             timeText = splittedMessage[2];
         }
 
         DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
         Date date = format.parse(dateText + " " + timeText);
         this.create(userId, taskName, isPinned, isDone, order, date);
         return new TextMessage("success");
     }
 
     public Todo create(String userId, String taskName, Boolean isPinned, Boolean isDone, Long order, Date date) {
         Todo todo = new Todo();
         todo.setId(UUID.randomUUID().toString());
         todo.setTaskName(taskName);
         todo.setUserId(userId);
         todo.setIsDone(isDone);
         todo.setIsPinned(isPinned);
         todo.setOrder(order);
         todo.setDate(date);
 
         Todo result = todoRepository.save(todo);
         log.info("Saved todo {}", result);
 
         return result;
     }
 
     public Todo update(String id, String userId, Boolean isPinned, Boolean isDone, Long order) {
         Optional<Todo> result = todoRepository.findByIdAndUserId(id, userId);
         require(result.isPresent(), "Resource not found");
         System.out.println("result " + result);
         Todo todo = result.get();
         todo.setIsPinned(isPinned);
         todo.setIsDone(isDone);
         todo.setOrder(order);
 
         Todo updatedTodo = todoRepository.save(todo);
         log.info("Updated todo {}", updatedTodo);
         return updatedTodo;
     }
+
+    public List<Todo> listTodos(String userId) {
+        List<Todo> todoList = todoRepository.findByUserId(userId);
+        return todoList;
+    }
 }
diff --git a/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java b/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
index 4dcb84c..aa86948 100644
--- a/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
+++ b/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
@@ -13,5 +13,3 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Optional;
+import java.util.*;
 
@@ -23,87 +21,120 @@ import static org.mockito.Mockito.when;
 public class TodoServiceTest {
     private TodoService todoService;
 
     @Mock
     private TodoRepository todoRepository;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         todoService = new TodoService(todoRepository);
     }
 
     @Test
     public void testCreateTodo() {
         String mockUserId = "U1";
         String mockTaskName = "mock-task";
         Boolean mockIsPinned = false;
         Boolean mockIsDone = false;
         Long mockOrder = 0L;
         Date mockDate = new Date();
 
         Todo mockTodo = new Todo();
         mockTodo.setUserId(mockUserId);
         mockTodo.setTaskName(mockTaskName);
         mockTodo.setOrder(mockOrder);
         mockTodo.setIsPinned(mockIsPinned);
         mockTodo.setIsDone(mockIsDone);
         mockTodo.setDate(mockDate);
 
 
         when(todoRepository.save(any())).thenReturn(mockTodo);
 
         Todo actual = todoService.create(mockUserId, mockTaskName, mockIsPinned, mockIsDone, mockOrder, mockDate);
 
         verify(todoRepository, times(1)).save(any());
 
         Assert.assertEquals(mockTaskName, actual.getTaskName());
         Assert.assertEquals(mockUserId, actual.getUserId());
         Assert.assertEquals(mockOrder, actual.getOrder());
         Assert.assertEquals(mockIsDone, actual.getIsDone());
         Assert.assertEquals(mockIsPinned, actual.getIsPinned());
         Assert.assertEquals(mockDate, actual.getDate());
     }
 
     @Test
     public void testUpdateSuccess() {
         String mockUserId = "U1";
         String mockTaskName = "mock-task";
         Boolean mockIsPinned = false;
         Boolean mockIsDone = false;
         Long mockOrder = 0L;
         Date mockDate = new Date();
 
         Todo mockTodo = new Todo();
         mockTodo.setUserId(mockUserId);
         mockTodo.setTaskName(mockTaskName);
         mockTodo.setOrder(mockOrder);
         mockTodo.setIsPinned(mockIsPinned);
         mockTodo.setIsDone(mockIsDone);
         mockTodo.setDate(mockDate);
 
         Optional<Todo> mockTodoOpt = Optional.of(mockTodo);
 
         when(todoRepository.findByIdAndUserId(any(), any())).thenReturn(mockTodoOpt);
         when(todoRepository.save(any())).thenReturn(mockTodoOpt.get());
 
         Todo actual = todoService.update("AAA", "USERID", false, false, 0L);
 
         verify(todoRepository, times(1)).findByIdAndUserId(any(), any());
         verify(todoRepository, times(1)).save(any());
 
         Assert.assertEquals(mockUserId, actual.getUserId());
         Assert.assertEquals(mockTaskName, actual.getTaskName());
         Assert.assertEquals(mockOrder, actual.getOrder());
         Assert.assertEquals(mockIsDone, actual.getIsDone());
         Assert.assertEquals(mockIsPinned, actual.getIsPinned());
         Assert.assertEquals(mockDate, actual.getDate());
     }
 
+    @Test
+    public void testListTodosSuccess() {
+        String mockUserId = "U1";
+        String mockTaskName = "mock-task";
+        Boolean mockIsPinned = false;
+        Boolean mockIsDone = false;
+        Long mockOrder = 0L;
+        Date mockDate = new Date();
+
+        Todo mockTodo = new Todo();
+        mockTodo.setUserId(mockUserId);
+        mockTodo.setTaskName(mockTaskName);
+        mockTodo.setOrder(mockOrder);
+        mockTodo.setIsPinned(mockIsPinned);
+        mockTodo.setIsDone(mockIsDone);
+        mockTodo.setDate(mockDate);
+
+        when(todoRepository.findByUserId(any())).thenReturn(Arrays.asList(mockTodo));;
+
+        List<Todo> actual = todoService.listTodos("AAA");
+
+        verify(todoRepository, times(1)).findByUserId(any());
+
+        Assert.assertEquals(1, actual.size());
+
+        Assert.assertEquals(mockUserId, actual.get(0).getUserId());
+        Assert.assertEquals(mockTaskName, actual.get(0).getTaskName());
+        Assert.assertEquals(mockOrder, actual.get(0).getOrder());
+        Assert.assertEquals(mockIsDone, actual.get(0).getIsDone());
+        Assert.assertEquals(mockIsPinned, actual.get(0).getIsPinned());
+        Assert.assertEquals(mockDate, actual.get(0).getDate());
+    }
+
     @Test
     public void test() throws ParseException {
         String test = "2/1/2018 12:00";
         DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
         Date date = format.parse(test);
         System.out.println(date);
     }
 }

commit 7a6a2ccb5c8ee301682db76042a0ad34a85a75be
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Mon Aug 20 17:01:03 2018 +0700

    ADD unit test

diff --git a/src/main/java/com/wanichnun/lineexam/controller/TodoController.java b/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
new file mode 100644
index 0000000..1dc6d1d
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/controller/TodoController.java
@@ -0,0 +1,10 @@
+package com.wanichnun.lineexam.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(path = "/api/v1/todos")
+public class TodoController {
+
+}
diff --git a/src/main/java/com/wanichnun/lineexam/service/TodoService.java b/src/main/java/com/wanichnun/lineexam/service/TodoService.java
index b785493..5c1d7da 100644
--- a/src/main/java/com/wanichnun/lineexam/service/TodoService.java
+++ b/src/main/java/com/wanichnun/lineexam/service/TodoService.java
@@ -21,62 +21,62 @@ import static org.valid4j.Assertive.require;
 @Slf4j
 @Service
 public class TodoService {
 
     private TodoRepository todoRepository;
 
     @Autowired
     public TodoService(TodoRepository todoRepository) {
         this.todoRepository = todoRepository;
     }
 
     public TextMessage handleTodoCreateRequest(String userId, String message) throws ParseException {
         Boolean isPinned = false;
         Boolean isDone = false;
         Long order = 0L;
 
         String[] splittedMessage = message.split(" : ");
         require(splittedMessage.length >= 2 && splittedMessage.length <= 3, "Invalid text format");
 
         String taskName = splittedMessage[0];
         String dateText = splittedMessage[1];
         String timeText = "12:00";
         if (splittedMessage.length > 2) {
             timeText = splittedMessage[2];
         }
 
         DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
         Date date = format.parse(dateText + " " + timeText);
         this.create(userId, taskName, isPinned, isDone, order, date);
         return new TextMessage("success");
     }
 
     public Todo create(String userId, String taskName, Boolean isPinned, Boolean isDone, Long order, Date date) {
         Todo todo = new Todo();
         todo.setId(UUID.randomUUID().toString());
         todo.setTaskName(taskName);
         todo.setUserId(userId);
         todo.setIsDone(isDone);
         todo.setIsPinned(isPinned);
         todo.setOrder(order);
         todo.setDate(date);
 
         Todo result = todoRepository.save(todo);
         log.info("Saved todo {}", result);
 
         return result;
     }
 
     public Todo update(String id, String userId, Boolean isPinned, Boolean isDone, Long order) {
         Optional<Todo> result = todoRepository.findByIdAndUserId(id, userId);
         require(result.isPresent(), "Resource not found");
-
+        System.out.println("result " + result);
         Todo todo = result.get();
         todo.setIsPinned(isPinned);
         todo.setIsDone(isDone);
         todo.setOrder(order);
 
         Todo updatedTodo = todoRepository.save(todo);
         log.info("Updated todo {}", updatedTodo);
         return updatedTodo;
     }
 }
diff --git a/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java b/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
index 62897f8..4dcb84c 100644
--- a/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
+++ b/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
@@ -15,2 +15,3 @@ import java.util.Date;
 import java.util.Locale;
+import java.util.Optional;
 
@@ -22,52 +23,87 @@ import static org.mockito.Mockito.when;
 public class TodoServiceTest {
     private TodoService todoService;
 
     @Mock
     private TodoRepository todoRepository;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         todoService = new TodoService(todoRepository);
     }
 
     @Test
     public void testCreateTodo() {
         String mockUserId = "U1";
         String mockTaskName = "mock-task";
         Boolean mockIsPinned = false;
         Boolean mockIsDone = false;
-        Long mockOrder = 1L;
+        Long mockOrder = 0L;
         Date mockDate = new Date();
 
         Todo mockTodo = new Todo();
         mockTodo.setUserId(mockUserId);
         mockTodo.setTaskName(mockTaskName);
         mockTodo.setOrder(mockOrder);
         mockTodo.setIsPinned(mockIsPinned);
         mockTodo.setIsDone(mockIsDone);
         mockTodo.setDate(mockDate);
 
 
         when(todoRepository.save(any())).thenReturn(mockTodo);
 
         Todo actual = todoService.create(mockUserId, mockTaskName, mockIsPinned, mockIsDone, mockOrder, mockDate);
 
         verify(todoRepository, times(1)).save(any());
 
         Assert.assertEquals(mockTaskName, actual.getTaskName());
         Assert.assertEquals(mockUserId, actual.getUserId());
         Assert.assertEquals(mockOrder, actual.getOrder());
         Assert.assertEquals(mockIsDone, actual.getIsDone());
         Assert.assertEquals(mockIsPinned, actual.getIsPinned());
         Assert.assertEquals(mockDate, actual.getDate());
     }
 
+    @Test
+    public void testUpdateSuccess() {
+        String mockUserId = "U1";
+        String mockTaskName = "mock-task";
+        Boolean mockIsPinned = false;
+        Boolean mockIsDone = false;
+        Long mockOrder = 0L;
+        Date mockDate = new Date();
+
+        Todo mockTodo = new Todo();
+        mockTodo.setUserId(mockUserId);
+        mockTodo.setTaskName(mockTaskName);
+        mockTodo.setOrder(mockOrder);
+        mockTodo.setIsPinned(mockIsPinned);
+        mockTodo.setIsDone(mockIsDone);
+        mockTodo.setDate(mockDate);
+
+        Optional<Todo> mockTodoOpt = Optional.of(mockTodo);
+
+        when(todoRepository.findByIdAndUserId(any(), any())).thenReturn(mockTodoOpt);
+        when(todoRepository.save(any())).thenReturn(mockTodoOpt.get());
+
+        Todo actual = todoService.update("AAA", "USERID", false, false, 0L);
+
+        verify(todoRepository, times(1)).findByIdAndUserId(any(), any());
+        verify(todoRepository, times(1)).save(any());
+
+        Assert.assertEquals(mockUserId, actual.getUserId());
+        Assert.assertEquals(mockTaskName, actual.getTaskName());
+        Assert.assertEquals(mockOrder, actual.getOrder());
+        Assert.assertEquals(mockIsDone, actual.getIsDone());
+        Assert.assertEquals(mockIsPinned, actual.getIsPinned());
+        Assert.assertEquals(mockDate, actual.getDate());
+    }
+
     @Test
     public void test() throws ParseException {
         String test = "2/1/2018 12:00";
         DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
         Date date = format.parse(test);
         System.out.println(date);
     }
 }

commit 486512b0d23600623b5f4266e4c6fd171df4d510
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Mon Aug 20 16:44:41 2018 +0700

    REFACTOR

diff --git a/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java b/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java
index df089ad..5ae46ba 100644
--- a/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java
+++ b/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java
@@ -23,48 +23,31 @@ import static org.valid4j.Assertive.require;
 @LineMessageHandler
 @Slf4j
 public class MessageHandler {
     String edit = "edit";
 
     @Autowired
     private TodoService todoService;
 
     @EventMapping
     public TextMessage handleTextMessageEvent(MessageEvent<TextMessageContent> event) throws ParseException {
         log.info("Got message this bot: {}", event);
         try {
             if (edit.equals(event.getMessage().getText())) {
                 return new TextMessage("https://google.com");
             }
             else {
                 String userId = event.getSource().getUserId();
-                Boolean isPinned = false;
-                Boolean isDone = false;
-                Long order = 0L;
-
-                String[] message = event.getMessage().getText().split(" : ");
-                require(message.length >= 2 && message.length <= 3, "Invalid text format");
-
-                String taskName = message[0];
-                String dateText = message[1];
-                String timeText = "12:00";
-                if (message.length > 2) {
-                    timeText = message[2];
-                }
-
-                DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
-                Date date = format.parse(dateText + " " + timeText);
-                todoService.create(userId, taskName, isPinned, isDone, order, date);
-
-                return new TextMessage("success");
+                String messageContent = event.getMessage().getText();
+                return todoService.handleTodoCreateRequest(userId, messageContent);
             }
         }
         catch (RequireViolation re) {
             return new TextMessage(re.getMessage());
         }
         catch (Exception e) {
             log.error("Error " + e);
             return new TextMessage("Wrong format");
         }
 
     }
 }
diff --git a/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java b/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
index 969a421..54dc943 100644
--- a/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
+++ b/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
@@ -5,3 +5,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
 
+import java.util.List;
+import java.util.Optional;
+
 public interface TodoRepository extends MongoRepository<Todo, String> {
+    Optional<Todo> findByIdAndUserId(String id, String userId);
 }
diff --git a/src/main/java/com/wanichnun/lineexam/service/TodoService.java b/src/main/java/com/wanichnun/lineexam/service/TodoService.java
index 2ec5f62..b785493 100644
--- a/src/main/java/com/wanichnun/lineexam/service/TodoService.java
+++ b/src/main/java/com/wanichnun/lineexam/service/TodoService.java
@@ -3,2 +3,3 @@ package com.wanichnun.lineexam.service;
 import com.linecorp.bot.model.message.TextMessage;
+import com.sun.org.apache.xpath.internal.operations.Bool;
 import com.wanichnun.lineexam.document.Todo;
@@ -9,30 +10,73 @@ import org.springframework.stereotype.Service;
 
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Locale;
+import java.util.Optional;
 import java.util.UUID;
 
+import static org.valid4j.Assertive.require;
+
 @Slf4j
 @Service
 public class TodoService {
 
     private TodoRepository todoRepository;
 
     @Autowired
     public TodoService(TodoRepository todoRepository) {
         this.todoRepository = todoRepository;
     }
 
+    public TextMessage handleTodoCreateRequest(String userId, String message) throws ParseException {
+        Boolean isPinned = false;
+        Boolean isDone = false;
+        Long order = 0L;
+
+        String[] splittedMessage = message.split(" : ");
+        require(splittedMessage.length >= 2 && splittedMessage.length <= 3, "Invalid text format");
+
+        String taskName = splittedMessage[0];
+        String dateText = splittedMessage[1];
+        String timeText = "12:00";
+        if (splittedMessage.length > 2) {
+            timeText = splittedMessage[2];
+        }
+
+        DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
+        Date date = format.parse(dateText + " " + timeText);
+        this.create(userId, taskName, isPinned, isDone, order, date);
+        return new TextMessage("success");
+    }
+
     public Todo create(String userId, String taskName, Boolean isPinned, Boolean isDone, Long order, Date date) {
         Todo todo = new Todo();
         todo.setId(UUID.randomUUID().toString());
+        todo.setTaskName(taskName);
         todo.setUserId(userId);
         todo.setIsDone(isDone);
         todo.setIsPinned(isPinned);
         todo.setOrder(order);
         todo.setDate(date);
 
         Todo result = todoRepository.save(todo);
         log.info("Saved todo {}", result);
 
         return result;
     }
+
+    public Todo update(String id, String userId, Boolean isPinned, Boolean isDone, Long order) {
+        Optional<Todo> result = todoRepository.findByIdAndUserId(id, userId);
+        require(result.isPresent(), "Resource not found");
+
+        Todo todo = result.get();
+        todo.setIsPinned(isPinned);
+        todo.setIsDone(isDone);
+        todo.setOrder(order);
+
+        Todo updatedTodo = todoRepository.save(todo);
+        log.info("Updated todo {}", updatedTodo);
+        return updatedTodo;
+    }
 }

commit 4528935ae443852ac091954c0e00bf65e3ac6967
Author: Wanichnun Sinpitak <kitaboons@gmail.com>
Date:   Mon Aug 20 15:29:17 2018 +0700

    INIT project

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e81b55d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,121 @@
+
+# Created by https://www.gitignore.io/api/java,gradle,jetbrains+all
+
+### Java ###
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+### JetBrains+all ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn.  Uncomment if using
+# auto-import.
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+### JetBrains+all Patch ###
+# Ignores the whole .idea folder and all .iml files
+# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
+
+.idea/
+
+# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
+
+*.iml
+modules.xml
+.idea/misc.xml
+*.ipr
+
+### Gradle ###
+.gradle
+/build/
+
+# Ignore Gradle GUI config
+gradle-app.setting
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+!gradle-wrapper.jar
+
+# Cache of project
+.gradletasknamecache
+
+# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
+# gradle/wrapper/gradle-wrapper.properties
+
+
+# End of https://www.gitignore.io/api/java,gradle,jetbrains+all
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..19a25b8
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,39 @@
+group 'com.wanichnun'
+version '1.0-SNAPSHOT'
+
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.3.RELEASE")
+    }
+}
+
+apply plugin: 'java'
+apply plugin: 'eclipse'
+apply plugin: 'idea'
+apply plugin: 'org.springframework.boot'
+apply plugin: 'io.spring.dependency-management'
+
+sourceCompatibility = 1.8
+
+repositories {
+    mavenCentral()
+    jcenter()
+}
+
+dependencies {
+    compile("org.springframework.boot:spring-boot-starter-web")
+    compile("org.springframework.boot:spring-boot-devtools")
+    compile("org.springframework.boot:spring-boot-starter-actuator")
+    compile("org.springframework.boot:spring-boot-starter-data-mongodb")
+    compile('org.valid4j:valid4j:0.5.0')
+    compile('joda-time:joda-time:2.9.9')
+    compile 'com.linecorp.bot:line-bot-spring-boot:2.0.0'
+    compile("org.projectlombok:lombok:1.18.2")
+
+    testCompile("de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.0.0")
+    testCompile("org.springframework.boot:spring-boot-starter-test")
+    testCompile group: 'junit', name: 'junit', version: '4.12'
+}
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
new file mode 100644
index 0000000..fac19a9
--- /dev/null
+++ b/docker/docker-compose.yml
@@ -0,0 +1,26 @@
+version: '3.5'
+services:
+#  web_dev:
+#    build: .
+#    ports:
+#      -  "4000:4000"
+#    volumes:
+#      -  .:/app
+#    environment:
+#      -  ENV=development
+#      -  PORT=4000
+#      -  DB=mongodb://mongodb:27017/todoDev
+  mongodb:
+    image: mongo:latest
+    container_name: "mongodb"
+    environment:
+      -  MONGO_DATA_DIR=/usr/data/db
+      -  MONGO_LOG_DIR=/dev/null
+    volumes:
+      -  ./data/db:/usr/data/db
+    ports:
+      -  27017:27017
+    command: mongod  --smallfiles  --logpath=/dev/null  #  --quiet
+networks:
+  default:
+    name: web_dev
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..01b8bf6
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..36cfab1
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Aug 20 11:24:52 ICT 2018
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..cccdd3d
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..381292b
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,2 @@
+rootProject.name = 'line-exam'
+
diff --git a/src/main/java/com/wanichnun/lineexam/Application.java b/src/main/java/com/wanichnun/lineexam/Application.java
new file mode 100644
index 0000000..b9f1ac0
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/Application.java
@@ -0,0 +1,13 @@
+package com.wanichnun.lineexam;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@EnableAutoConfiguration
+public class Application {
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+    }
+}
diff --git a/src/main/java/com/wanichnun/lineexam/document/Todo.java b/src/main/java/com/wanichnun/lineexam/document/Todo.java
new file mode 100644
index 0000000..c9ebe0b
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/document/Todo.java
@@ -0,0 +1,20 @@
+package com.wanichnun.lineexam.document;
+
+import lombok.Data;
+import org.springframework.data.mongodb.core.mapping.Document;
+import org.springframework.data.mongodb.core.mapping.Field;
+
+import java.util.Date;
+
+@Data
+@Document(collection = "Todo")
+public class Todo {
+    @Field(value = "id")
+    private String id;
+    private String userId;
+    private String taskName;
+    private Boolean isPinned;
+    private Boolean isDone;
+    private Long order;
+    private Date date;
+}
diff --git a/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java b/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java
new file mode 100644
index 0000000..df089ad
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/handler/MessageHandler.java
@@ -0,0 +1,70 @@
+package com.wanichnun.lineexam.handler;
+
+import com.linecorp.bot.model.event.MessageEvent;
+import com.linecorp.bot.model.event.message.TextMessageContent;
+import com.linecorp.bot.model.message.TextMessage;
+import com.linecorp.bot.spring.boot.annotation.EventMapping;
+import com.linecorp.bot.spring.boot.annotation.LineMessageHandler;
+import com.sun.org.apache.xpath.internal.operations.Bool;
+import com.wanichnun.lineexam.document.Todo;
+import com.wanichnun.lineexam.service.TodoService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.valid4j.errors.RequireViolation;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import static org.valid4j.Assertive.require;
+
+@LineMessageHandler
+@Slf4j
+public class MessageHandler {
+    String edit = "edit";
+
+    @Autowired
+    private TodoService todoService;
+
+    @EventMapping
+    public TextMessage handleTextMessageEvent(MessageEvent<TextMessageContent> event) throws ParseException {
+        log.info("Got message this bot: {}", event);
+        try {
+            if (edit.equals(event.getMessage().getText())) {
+                return new TextMessage("https://google.com");
+            }
+            else {
+                String userId = event.getSource().getUserId();
+                Boolean isPinned = false;
+                Boolean isDone = false;
+                Long order = 0L;
+
+                String[] message = event.getMessage().getText().split(" : ");
+                require(message.length >= 2 && message.length <= 3, "Invalid text format");
+
+                String taskName = message[0];
+                String dateText = message[1];
+                String timeText = "12:00";
+                if (message.length > 2) {
+                    timeText = message[2];
+                }
+
+                DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
+                Date date = format.parse(dateText + " " + timeText);
+                todoService.create(userId, taskName, isPinned, isDone, order, date);
+
+                return new TextMessage("success");
+            }
+        }
+        catch (RequireViolation re) {
+            return new TextMessage(re.getMessage());
+        }
+        catch (Exception e) {
+            log.error("Error " + e);
+            return new TextMessage("Wrong format");
+        }
+
+    }
+}
diff --git a/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java b/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
new file mode 100644
index 0000000..969a421
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/repository/TodoRepository.java
@@ -0,0 +1,7 @@
+package com.wanichnun.lineexam.repository;
+
+import com.wanichnun.lineexam.document.Todo;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+public interface TodoRepository extends MongoRepository<Todo, String> {
+}
diff --git a/src/main/java/com/wanichnun/lineexam/service/TodoService.java b/src/main/java/com/wanichnun/lineexam/service/TodoService.java
new file mode 100644
index 0000000..2ec5f62
--- /dev/null
+++ b/src/main/java/com/wanichnun/lineexam/service/TodoService.java
@@ -0,0 +1,38 @@
+package com.wanichnun.lineexam.service;
+
+import com.linecorp.bot.model.message.TextMessage;
+import com.wanichnun.lineexam.document.Todo;
+import com.wanichnun.lineexam.repository.TodoRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.UUID;
+
+@Slf4j
+@Service
+public class TodoService {
+
+    private TodoRepository todoRepository;
+
+    @Autowired
+    public TodoService(TodoRepository todoRepository) {
+        this.todoRepository = todoRepository;
+    }
+
+    public Todo create(String userId, String taskName, Boolean isPinned, Boolean isDone, Long order, Date date) {
+        Todo todo = new Todo();
+        todo.setId(UUID.randomUUID().toString());
+        todo.setUserId(userId);
+        todo.setIsDone(isDone);
+        todo.setIsPinned(isPinned);
+        todo.setOrder(order);
+        todo.setDate(date);
+
+        Todo result = todoRepository.save(todo);
+        log.info("Saved todo {}", result);
+
+        return result;
+    }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..95bb834
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,14 @@
+line:
+  bot:
+    channelToken: 8G/19OV1PFe3LtbbUIK1YhzQBtigpfk2ncxGA+Ul3yzDhRKEl2O6rJUj/RmMMe93lojH6foXpZ5Ruw6CpN6+/klIWoQT3dIGI3iMl6aYvd8qYjcpSMpC4/WsYi6OaSUhf+UADvVyOBdHvIPpN8dL5QdB04t89/1O/w1cDnyilFU=
+    channelSecret: 52f1f89f193bd08fa092371e9865afc8
+
+spring:
+  devtools:
+    restart:
+      enabled: true
+      additional-paths: src
+  data:
+      mongodb:
+        host: localhost
+        database: todo
\ No newline at end of file
diff --git a/src/test/java/com/wanichnun/lineexam/handler/MessageHandlerTest.java b/src/test/java/com/wanichnun/lineexam/handler/MessageHandlerTest.java
new file mode 100644
index 0000000..afadfe1
--- /dev/null
+++ b/src/test/java/com/wanichnun/lineexam/handler/MessageHandlerTest.java
@@ -0,0 +1,18 @@
+package com.wanichnun.lineexam.handler;
+
+import com.linecorp.bot.model.event.message.TextMessageContent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+public class MessageHandlerTest {
+    @Autowired
+    MessageHandler messageHandler;
+
+//    @Test
+//    public void testHandleTextMessageEvent() {
+//        TextMessageContent textMessageContent = new TextMessageContent("123", "edit");
+//    }
+}
diff --git a/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java b/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
new file mode 100644
index 0000000..62897f8
--- /dev/null
+++ b/src/test/java/com/wanichnun/lineexam/service/TodoServiceTest.java
@@ -0,0 +1,73 @@
+package com.wanichnun.lineexam.service;
+
+import com.wanichnun.lineexam.document.Todo;
+import com.wanichnun.lineexam.repository.TodoRepository;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class TodoServiceTest {
+    private TodoService todoService;
+
+    @Mock
+    private TodoRepository todoRepository;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        todoService = new TodoService(todoRepository);
+    }
+
+    @Test
+    public void testCreateTodo() {
+        String mockUserId = "U1";
+        String mockTaskName = "mock-task";
+        Boolean mockIsPinned = false;
+        Boolean mockIsDone = false;
+        Long mockOrder = 1L;
+        Date mockDate = new Date();
+
+        Todo mockTodo = new Todo();
+        mockTodo.setUserId(mockUserId);
+        mockTodo.setTaskName(mockTaskName);
+        mockTodo.setOrder(mockOrder);
+        mockTodo.setIsPinned(mockIsPinned);
+        mockTodo.setIsDone(mockIsDone);
+        mockTodo.setDate(mockDate);
+
+
+        when(todoRepository.save(any())).thenReturn(mockTodo);
+
+        Todo actual = todoService.create(mockUserId, mockTaskName, mockIsPinned, mockIsDone, mockOrder, mockDate);
+
+        verify(todoRepository, times(1)).save(any());
+
+        Assert.assertEquals(mockTaskName, actual.getTaskName());
+        Assert.assertEquals(mockUserId, actual.getUserId());
+        Assert.assertEquals(mockOrder, actual.getOrder());
+        Assert.assertEquals(mockIsDone, actual.getIsDone());
+        Assert.assertEquals(mockIsPinned, actual.getIsPinned());
+        Assert.assertEquals(mockDate, actual.getDate());
+    }
+
+    @Test
+    public void test() throws ParseException {
+        String test = "2/1/2018 12:00";
+        DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
+        Date date = format.parse(test);
+        System.out.println(date);
+    }
+}
