|
|
@ -25,8 +25,12 @@ import org.springframework.test.web.servlet.result.MockMvcResultHandlers; |
|
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|
|
|
import org.springframework.web.context.WebApplicationContext; |
|
|
|
import org.springframework.web.context.WebApplicationContext; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileReader; |
|
|
|
import java.io.FileReader; |
|
|
|
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Random; |
|
|
|
import java.util.Random; |
|
|
|
|
|
|
|
|
|
|
@ -86,7 +90,7 @@ class DemoApplicationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void loadData() throws FileNotFoundException { |
|
|
|
void loadData() throws FileNotFoundException { |
|
|
|
Gson gson = new Gson(); |
|
|
|
Gson gson = new Gson(); |
|
|
|
MyGarbage g = gson.fromJson(new FileReader("src/main/resources/garbage.json"), MyGarbage.class); |
|
|
|
MyGarbage g = gson.fromJson(new InputStreamReader(new FileInputStream("src/main/resources/garbage.json"), StandardCharsets.UTF_8), MyGarbage.class); |
|
|
|
for (Garbage garbage : g.getList()) { |
|
|
|
for (Garbage garbage : g.getList()) { |
|
|
|
garbageDao.save(garbage); |
|
|
|
garbageDao.save(garbage); |
|
|
|
} |
|
|
|
} |
|
|
|