diff --git a/pom.xml b/pom.xml
index b8f142e..023925c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -109,6 +109,14 @@
1.4.200
runtime
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.11.4
+ test
+
diff --git a/preflist.geojson b/preflist.geojson
index 5e86e5d..7dd7e44 100644
--- a/preflist.geojson
+++ b/preflist.geojson
@@ -1,4 +1,5 @@
-{"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},"features":[{"type":"Feature","properties":{"name":"北海道","id":"1"},"geometry":{"coordinates":[143.35,43.479],"type":"Point"}}
+{"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},"features":[
+{"type":"Feature","properties":{"name":"北海道","id":"1"},"geometry":{"coordinates":[143.35,43.479],"type":"Point"}}
,{"type":"Feature","properties":{"name":"青森県","id":"2"},"geometry":{"coordinates":[140.609,40.907],"type":"Point"}}
,{"type":"Feature","properties":{"name":"岩手県","id":"3"},"geometry":{"coordinates":[141.559,39.65],"type":"Point"}}
,{"type":"Feature","properties":{"name":"宮城県","id":"4"},"geometry":{"coordinates":[141.29,38.387],"type":"Point"}}
diff --git a/src/main/java/osm/surveyor/task/index/IndexController.java b/src/main/java/osm/surveyor/task/index/IndexController.java
index f6bcd89..512973d 100644
--- a/src/main/java/osm/surveyor/task/index/IndexController.java
+++ b/src/main/java/osm/surveyor/task/index/IndexController.java
@@ -1,5 +1,6 @@
package osm.surveyor.task.index;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -9,10 +10,11 @@
@RestController
public class IndexController {
+ @Value("${task-bldg.osm-data.url}")
+ private String url;
@GetMapping("/index")
public String index() {
- String url = "http://surveyor.mydns.jp/osm-data";
try {
RestTemplate restTemplate = new RestTemplate();
System.out.println(String.format("INFO: httpGet(%s)", url));
diff --git a/src/main/java/osm/surveyor/task/plateau/PlateauController.java b/src/main/java/osm/surveyor/task/plateau/PlateauController.java
new file mode 100644
index 0000000..6f6533a
--- /dev/null
+++ b/src/main/java/osm/surveyor/task/plateau/PlateauController.java
@@ -0,0 +1,62 @@
+package osm.surveyor.task.plateau;
+
+import java.nio.file.*;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.PathResource;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+@RestController
+public class PlateauController {
+ @Value("${task-bldg.osm-data.url}")
+ private String url; // task-bldg.osm-data.url=http://surveyor.mydns.jp/osm-data
+
+ @Value("${task-bldg.plateau.dir}")
+ private String dir; // task-bldg.plateau.dir=plateau-data
+
+ @GetMapping(value = "/plateau/{citycode}}")
+ public String getPlateau(@PathVariable("citycode") String citycode) throws Exception {
+ try {
+ Path base = Path.of(dir);
+ if (Files.exists(base)) {
+ Files.createDirectory(base);
+ }
+ Path city = Path.of(dir, citycode);
+ if (Files.exists(city)) {
+ Files.createDirectory(city);
+ }
+ return "OK";
+ }
+ catch (Exception e) {
+ return e.toString();
+ }
+
+ /*
+ Path path = Path.of(dir.toString(), fileName);
+ PathResource resource = new PathResource(path);
+
+ try {
+ RestTemplate restTemplate = new RestTemplate();
+ System.out.println(String.format("INFO: httpGet(%s)", url));
+ ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
+ HttpStatus httpStatus = response.getStatusCode();
+ if (httpStatus.isError()) {
+ System.out.println("ERROE: Can not access '"+ url +"'");
+ throw new Exception("ERROE: Can not access '"+ url +"'");
+ }
+ String body = response.getBody();
+ return body;
+ }
+ catch (Exception e) {
+ return e.toString();
+ }
+ */
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index fa850cd..060effe 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -17,3 +17,7 @@
spring.h2.console.settings.web-allow-others=true
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=update
+
+# task-bldg orignal properties
+task-bldg.osm-data.url=http://surveyor.mydns.jp/osm-data
+task-bldg.plateau.dir=plateau-data
diff --git a/src/test/java/osm/surveyor/task/plateau/PlateauControllerTest.java b/src/test/java/osm/surveyor/task/plateau/PlateauControllerTest.java
new file mode 100644
index 0000000..81852a4
--- /dev/null
+++ b/src/test/java/osm/surveyor/task/plateau/PlateauControllerTest.java
@@ -0,0 +1,75 @@
+package osm.surveyor.task.plateau;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.util.FileSystemUtils;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@SpringBootTest
+@WebMvcTest(PlateauController.class)
+class PlateauControllerTest {
+
+ @Autowired
+ private MockMvc mvc;
+ private final String rootUrl = "/plateau";
+ private static final String dirStr = "plateau-data"; // task-bldg.plateau.dir=plateau-data
+
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
+ Path dir = Path.of(dirStr);
+ FileSystemUtils.deleteRecursively(dir);
+ }
+
+ @AfterAll
+ static void tearDownAfterClass() throws Exception {
+ }
+
+ @BeforeEach
+ void setUp() throws Exception {
+ }
+
+ @AfterEach
+ void tearDown() throws Exception {
+ }
+
+ @Test
+ @DisplayName("'./plateau/01100' is Sapporo 2020")
+ void testGetPlateau() throws IOException {
+ String urlPath = "/01100";
+
+ MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(rootUrl + urlPath))
+ .andExpect(status().isOk())
+ .andExpect(content().json("OK"))
+ .andReturn();
+
+ Path base = Path.of(dirStr);
+ boolean exists = Files.exists(base);
+ assertThat(exists);
+ }
+}