๐ Spring/Spring REST API
2021.03.16
์ค๊ฐ ์๋ต... POST ์์ฒญ์ผ๋ก ๋ณด๋ด๋ฉด,, POST http://localhost:8080/boards/1/pockets requestBody : { "title" : "pocket title" } ์๋ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค. ๋์ถฉ ๋ณด๋๊น, PocketController์ addPocket ๋ฉ์๋์ linkTo๋ฅผ ์คํํ๋ค๊ฐ ์๋ฌ๊ฐ ๋ ๊ฒ๊ฐ๋ค. boardId๊ฐ์ ํ์ฅํ๊ธฐ ์ํ ๋ณ์๊ฐ์ด ์ถฉ๋ถํ์ง ์๋ค..? ๋ผ๊ณ ๋จ๋๋ฐ ๋ญ ๋ง์ด์ง.. @PostMapping public ResponseEntity addPocket(@PathVariable Long boardId, @RequestBody PocketDto pocketDto) throws NotFoundException { System.out.println("boar..
๐ Spring
2020.12.12
JUnit์ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ์ ๋ชจ๋ฅด์ ๋ค๋ฉด [JUnit] - JUnit5 ์์ํ๊ธฐ ๋ฅผ ์ฐธ๊ณ ํ์๊ธธ ๋ฐ๋๋๋ค. [JUnit] - JUnit5 ์์ํ๊ธฐ JUnit์ด๋? ์๋ฐ์ฉ ๋จ์ ํ
์คํธ(Unit Test) ๋๊ตฌ ์ฅ์ ํ
์คํธ๋ฅผ ํ๊ธฐ ์ํด ์ผ์ผํ System.out.prinlnt ๋ก ์ฐ์ด๋ณผ ํ์๊ฐ ์๋ค. @Test ๋ฉ์๋๊ฐ ํธ์ถ๋ ๋ ๋ง๋ค ์๋ก์ด ์ธ์คํด์ค๊ฐ ์์ฑ๋์ด ๋
๋ฆฝ์ ์ธ ํ
์คํธ iseunghan.tistory.com JUnit ๊ธฐ๋ณธ Annotation @BeforeAll ํด๋น annotation์ด ๋ฌ๋ฆฐ ๋ฉ์๋๋ ๋ชจ๋ ๋ฉ์๋๊ฐ ์คํ๋๊ธฐ ์ ์ ๊ฐ์ฅ ๋จผ์ ์คํ๋๋ค. ๋ฐ๋์ static ์ผ๋ก ์ ์ธ ๋์ด์ผ ํ๋ค. ์ด์ ์ @BeforeClass ์ ๋์ผ @BeforeAll static void before() { // ..
๐ Spring
2020.12.12
JUnit์ด๋? ์๋ฐ์ฉ ๋จ์ ํ
์คํธ(Unit Test) ๋๊ตฌ ์ฅ์ ํ
์คํธ๋ฅผ ํ๊ธฐ ์ํด ์ผ์ผํ System.out.prinlnt ๋ก ์ฐ์ด๋ณผ ํ์๊ฐ ์๋ค. @Test ๋ฉ์๋๊ฐ ํธ์ถ๋ ๋ ๋ง๋ค ์๋ก์ด ์ธ์คํด์ค๊ฐ ์์ฑ๋์ด ๋
๋ฆฝ์ ์ธ ํ
์คํธ๊ฐ ์ด๋ฃจ์ด์ง๋ค. ๋จ์ (assert) ๋ฉ์๋๋ก ํ
์คํธ ์ผ์ด์ค์ ์ํ ๊ฒฐ๊ณผ๋ฅผ ํ๋ณํ ์ ์๋ค. TDD(ํ
์คํธ ์ฃผ๋ ๊ฐ๋ฐ)์ด ๊ฐ๋ฅํ๋ค. ์์ ํ๊ธฐ ๊ฐ๋ฐ ํ๊ฒฝ IntelliJ IDEA (2020.2.4) JDK 1.8 JUnit 5 Maven Dependency org.junit.jupiter junit-jupiter-api 5.7.0 test mvnrepository.com/search?q=junit Maven Repository: junit Module "junit-jupiter-a..
๐ Spring
2020.12.12
Personal Access Token Github ์ ์ - profile - Settings Settings / Developer settings / Personal access tokens ์ค๋ฅธ์ชฝ ์๋จ์ Generate new token์ ํด๋ฆญํด์ค๋ค. Note ์๋ ์ด ํ ํฐ์ ๋ฌด์์ ์ํด ์ฌ์ฉํ๋์ง๋ฅผ ๋ฉ๋ชจํ๋ ๊ฒ์ด๊ตฌ, ์๋ scopes๋ repo๋ง ์ฒดํฌํด์ฃผ๊ณ ์๋์ Generate Token์ ๋๋ฌ์ค๋ค. ์ด๋ฌ๋ฉด ๋! ์ด์ ํ ํฐ์ ๋ณต์ฌํด์ ์ฌ์ฉํ๋ฉด ๋๋ค. ์ด ํ ํฐ์ ๋ค์ ๋ณผ ์ ์์ผ๋ ์บก์ฒํ๊ฑฐ๋ ์ด๋ ์ ์ด๋๊ธฐ๋ฅผ ๋ฐ๋๋ค.
๐ Spring
2020.12.11
Github API ์ฌ์ฉ ํ๊ธฐ github-api.kohsuke.org/index.html GitHub API for Java – What is this? This library defines an object oriented representation of the GitHub API. By "object oriented" we mean there are classes that correspond to the domain model of GitHub (such as GHUser and GHRepository), operations that act on them as defined a github-api.kohsuke.org ์ ํ์ด์ง๋ฅผ ๋ค์ด๊ฐ๋ณด๋ฉด, ์....... ์์๋ถํฐ ๋ง๋งํ๋ค. ์์์ ์์ Down..
๐ Spring/Spring REST API
2020.09.12
๋น์ฆ๋์ค ๋ก์ง ์ ์ฉ ๋๋์ง ์๋ต ๋ฉ์์ง ํ์ธ offline ๊ณผ free ๊ฐ ํ์ธ ๋น์ฆ๋์ค ๋ก์ง ์ผ๋จ offline์ location์ ๊ฐ์ด ๋ค์ด์์ผ๋ฉด ์คํ๋ผ์ธ์ด๊ณ , ๊ฐ์ด ์์ผ๋ฉด ์จ๋ผ์ธ์ผ๋ก ์งํ์ด ๋๋ค. free๊ฐ์ basePrice์, MaxPrice๊ฐ ๋ ๋ค 0์ผ๋ , free ์ด๋ค. Event.class ๋๋ฉ์ธ ํด๋์ค์๋ค๊ฐ ๋น์ฆ๋์ค ๋ก์ง์ ์ ์ฉ์์ผ์ค๋ค. public void update() { this.free = (basePrice == 0) && (maxPrice == 0); this.offline = location != null; } EventTests.class @Test public void testOffine() { // Given Event event = Event.builder() ...