diff --git a/.gradle/7.6.1/checksums/checksums.lock b/.gradle/7.6.1/checksums/checksums.lock new file mode 100644 index 0000000..f23c484 Binary files /dev/null and b/.gradle/7.6.1/checksums/checksums.lock differ diff --git a/.gradle/7.6.1/checksums/md5-checksums.bin b/.gradle/7.6.1/checksums/md5-checksums.bin new file mode 100644 index 0000000..5a2d062 Binary files /dev/null and b/.gradle/7.6.1/checksums/md5-checksums.bin differ diff --git a/.gradle/7.6.1/checksums/sha1-checksums.bin b/.gradle/7.6.1/checksums/sha1-checksums.bin new file mode 100644 index 0000000..281e575 Binary files /dev/null and b/.gradle/7.6.1/checksums/sha1-checksums.bin differ diff --git a/.gradle/7.6.1/dependencies-accessors/dependencies-accessors.lock b/.gradle/7.6.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..bb7cbd1 Binary files /dev/null and b/.gradle/7.6.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/.gradle/7.6.1/dependencies-accessors/gc.properties b/.gradle/7.6.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/7.6.1/executionHistory/executionHistory.bin b/.gradle/7.6.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..c1238b4 Binary files /dev/null and b/.gradle/7.6.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.6.1/executionHistory/executionHistory.lock b/.gradle/7.6.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..a924ddc Binary files /dev/null and b/.gradle/7.6.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.6.1/fileChanges/last-build.bin b/.gradle/7.6.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/7.6.1/fileChanges/last-build.bin differ diff --git a/.gradle/7.6.1/fileHashes/fileHashes.bin b/.gradle/7.6.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..cd9fbe8 Binary files /dev/null and b/.gradle/7.6.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.6.1/fileHashes/fileHashes.lock b/.gradle/7.6.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..69f6eb1 Binary files /dev/null and b/.gradle/7.6.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.6.1/fileHashes/resourceHashesCache.bin b/.gradle/7.6.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..4c33621 Binary files /dev/null and b/.gradle/7.6.1/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/7.6.1/gc.properties b/.gradle/7.6.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..14419f0 Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..3576646 --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Wed Aug 14 14:17:06 KST 2024 +gradle.version=7.6.1 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..9478208 Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe new file mode 100644 index 0000000..ab3a78f Binary files /dev/null and b/.gradle/file-system.probe differ diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..4b77bc4 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +landlog \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7d3b3e8 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..668048d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build/classes/java/main/com/landvibe/landlog/controller/BlogController.class b/build/classes/java/main/com/landvibe/landlog/controller/BlogController.class new file mode 100644 index 0000000..786ae89 Binary files /dev/null and b/build/classes/java/main/com/landvibe/landlog/controller/BlogController.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/controller/BlogForm.class b/build/classes/java/main/com/landvibe/landlog/controller/BlogForm.class new file mode 100644 index 0000000..d6fd9af Binary files /dev/null and b/build/classes/java/main/com/landvibe/landlog/controller/BlogForm.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/controller/MemberController.class b/build/classes/java/main/com/landvibe/landlog/controller/MemberController.class index 6d0737d..38efa5e 100644 Binary files a/build/classes/java/main/com/landvibe/landlog/controller/MemberController.class and b/build/classes/java/main/com/landvibe/landlog/controller/MemberController.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/controller/MemberForm.class b/build/classes/java/main/com/landvibe/landlog/controller/MemberForm.class index 10f5ce3..b1e621e 100644 Binary files a/build/classes/java/main/com/landvibe/landlog/controller/MemberForm.class and b/build/classes/java/main/com/landvibe/landlog/controller/MemberForm.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/controller/MemberLoginForm.class b/build/classes/java/main/com/landvibe/landlog/controller/MemberLoginForm.class new file mode 100644 index 0000000..87b87b0 Binary files /dev/null and b/build/classes/java/main/com/landvibe/landlog/controller/MemberLoginForm.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/domain/Blog.class b/build/classes/java/main/com/landvibe/landlog/domain/Blog.class new file mode 100644 index 0000000..8409b8c Binary files /dev/null and b/build/classes/java/main/com/landvibe/landlog/domain/Blog.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/domain/Member.class b/build/classes/java/main/com/landvibe/landlog/domain/Member.class index 7b2fa53..99f53f6 100644 Binary files a/build/classes/java/main/com/landvibe/landlog/domain/Member.class and b/build/classes/java/main/com/landvibe/landlog/domain/Member.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/repository/BlogRepository.class b/build/classes/java/main/com/landvibe/landlog/repository/BlogRepository.class new file mode 100644 index 0000000..2d01a9e Binary files /dev/null and b/build/classes/java/main/com/landvibe/landlog/repository/BlogRepository.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/repository/MemberRepository.class b/build/classes/java/main/com/landvibe/landlog/repository/MemberRepository.class index e0954e0..56273ef 100644 Binary files a/build/classes/java/main/com/landvibe/landlog/repository/MemberRepository.class and b/build/classes/java/main/com/landvibe/landlog/repository/MemberRepository.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/repository/MemoryBlogRepository.class b/build/classes/java/main/com/landvibe/landlog/repository/MemoryBlogRepository.class new file mode 100644 index 0000000..897b6bb Binary files /dev/null and b/build/classes/java/main/com/landvibe/landlog/repository/MemoryBlogRepository.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/repository/MemoryMemberRepository.class b/build/classes/java/main/com/landvibe/landlog/repository/MemoryMemberRepository.class index ca2c90e..d5cf190 100644 Binary files a/build/classes/java/main/com/landvibe/landlog/repository/MemoryMemberRepository.class and b/build/classes/java/main/com/landvibe/landlog/repository/MemoryMemberRepository.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/service/BlogService.class b/build/classes/java/main/com/landvibe/landlog/service/BlogService.class new file mode 100644 index 0000000..53d29cb Binary files /dev/null and b/build/classes/java/main/com/landvibe/landlog/service/BlogService.class differ diff --git a/build/classes/java/main/com/landvibe/landlog/service/MemberService.class b/build/classes/java/main/com/landvibe/landlog/service/MemberService.class index 4020fe9..b35d1c5 100644 Binary files a/build/classes/java/main/com/landvibe/landlog/service/MemberService.class and b/build/classes/java/main/com/landvibe/landlog/service/MemberService.class differ diff --git a/build/classes/java/test/com/landvibe/landlog/LandlogApplicationTests.class b/build/classes/java/test/com/landvibe/landlog/LandlogApplicationTests.class new file mode 100644 index 0000000..c95d9de Binary files /dev/null and b/build/classes/java/test/com/landvibe/landlog/LandlogApplicationTests.class differ diff --git a/build/classes/java/test/com/landvibe/landlog/repository/MemoryMemberRepositoryTest.class b/build/classes/java/test/com/landvibe/landlog/repository/MemoryMemberRepositoryTest.class new file mode 100644 index 0000000..6efbea5 Binary files /dev/null and b/build/classes/java/test/com/landvibe/landlog/repository/MemoryMemberRepositoryTest.class differ diff --git a/build/classes/java/test/com/landvibe/landlog/service/MemberServiceTest.class b/build/classes/java/test/com/landvibe/landlog/service/MemberServiceTest.class new file mode 100644 index 0000000..5a7d49d Binary files /dev/null and b/build/classes/java/test/com/landvibe/landlog/service/MemberServiceTest.class differ diff --git a/build/reports/tests/test/classes/com.landvibe.landlog.repository.MemoryMemberRepositoryTest.html b/build/reports/tests/test/classes/com.landvibe.landlog.repository.MemoryMemberRepositoryTest.html new file mode 100644 index 0000000..c17c96d --- /dev/null +++ b/build/reports/tests/test/classes/com.landvibe.landlog.repository.MemoryMemberRepositoryTest.html @@ -0,0 +1,116 @@ + + + + + +Test results - MemoryMemberRepositoryTest + + + + + +
+

MemoryMemberRepositoryTest

+ +
+ + + + + +
+
+ + + + + + + +
+
+
5
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.122s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestDurationResult
findAll()0.113spassed
findByEmail()0.002spassed
findById()0.002spassed
findByName()0.003spassed
save()0.002spassed
+
+
+ +
+ + diff --git a/build/reports/tests/test/css/base-style.css b/build/reports/tests/test/css/base-style.css new file mode 100644 index 0000000..4afa73e --- /dev/null +++ b/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/build/reports/tests/test/css/style.css b/build/reports/tests/test/css/style.css new file mode 100644 index 0000000..3dc4913 --- /dev/null +++ b/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/build/reports/tests/test/index.html b/build/reports/tests/test/index.html new file mode 100644 index 0000000..f60dfb3 --- /dev/null +++ b/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
5
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.122s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+com.landvibe.landlog.repository +5000.122s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+com.landvibe.landlog.repository.MemoryMemberRepositoryTest +5000.122s100%
+
+
+ +
+ + diff --git a/build/reports/tests/test/js/report.js b/build/reports/tests/test/js/report.js new file mode 100644 index 0000000..83bab4a --- /dev/null +++ b/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/build/reports/tests/test/packages/com.landvibe.landlog.repository.html b/build/reports/tests/test/packages/com.landvibe.landlog.repository.html new file mode 100644 index 0000000..a81970d --- /dev/null +++ b/build/reports/tests/test/packages/com.landvibe.landlog.repository.html @@ -0,0 +1,103 @@ + + + + + +Test results - Package com.landvibe.landlog.repository + + + + + +
+

Package com.landvibe.landlog.repository

+ +
+ + + + + +
+
+ + + + + + + +
+
+
5
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.122s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+MemoryMemberRepositoryTest +5000.122s100%
+
+
+ +
+ + diff --git a/build/resources/main/templates/blogs/blogList.html b/build/resources/main/templates/blogs/blogList.html new file mode 100644 index 0000000..63e5e5e --- /dev/null +++ b/build/resources/main/templates/blogs/blogList.html @@ -0,0 +1,37 @@ + + + +
+
+

의 블로그

+

+ 생성 +

+ + + + + + + + + + + + + + + + + + + +
#제목내용
수정 +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/build/resources/main/templates/blogs/createBlogForm.html b/build/resources/main/templates/blogs/createBlogForm.html new file mode 100644 index 0000000..1e611fe --- /dev/null +++ b/build/resources/main/templates/blogs/createBlogForm.html @@ -0,0 +1,20 @@ + + + +
+

의 블로그

+
+ +
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/build/resources/main/templates/blogs/updateBlogForm.html b/build/resources/main/templates/blogs/updateBlogForm.html new file mode 100644 index 0000000..5f4e1ca --- /dev/null +++ b/build/resources/main/templates/blogs/updateBlogForm.html @@ -0,0 +1,21 @@ + + + +
+

의 블로그

+
+ + +
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/build/resources/main/templates/home.html b/build/resources/main/templates/home.html index 109d59d..15a4e6f 100644 --- a/build/resources/main/templates/home.html +++ b/build/resources/main/templates/home.html @@ -6,6 +6,7 @@

Hello Spring

회원 기능

+ 로그인 회원 가입 회원 목록

diff --git a/build/resources/main/templates/members/createMemberForm.html b/build/resources/main/templates/members/createMemberForm.html index c0353f2..54898ae 100644 --- a/build/resources/main/templates/members/createMemberForm.html +++ b/build/resources/main/templates/members/createMemberForm.html @@ -7,6 +7,14 @@ +
+ + +
+
+ + +
diff --git a/build/resources/main/templates/members/loginForm.html b/build/resources/main/templates/members/loginForm.html new file mode 100644 index 0000000..405f17a --- /dev/null +++ b/build/resources/main/templates/members/loginForm.html @@ -0,0 +1,18 @@ + + + +
+
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/build/test-results/test/TEST-com.landvibe.landlog.repository.MemoryMemberRepositoryTest.xml b/build/test-results/test/TEST-com.landvibe.landlog.repository.MemoryMemberRepositoryTest.xml new file mode 100644 index 0000000..e5e1bdd --- /dev/null +++ b/build/test-results/test/TEST-com.landvibe.landlog.repository.MemoryMemberRepositoryTest.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/build/test-results/test/binary/output.bin b/build/test-results/test/binary/output.bin new file mode 100644 index 0000000..e69de29 diff --git a/build/test-results/test/binary/output.bin.idx b/build/test-results/test/binary/output.bin.idx new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/build/test-results/test/binary/output.bin.idx differ diff --git a/build/test-results/test/binary/results.bin b/build/test-results/test/binary/results.bin new file mode 100644 index 0000000..48b2462 Binary files /dev/null and b/build/test-results/test/binary/results.bin differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/BlogController.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/BlogController.class.uniqueId0 new file mode 100644 index 0000000..459ef38 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/BlogController.class.uniqueId0 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/MemoryBlogRepository.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/MemoryBlogRepository.class.uniqueId1 new file mode 100644 index 0000000..43ce57e Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/MemoryBlogRepository.class.uniqueId1 differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index 1a81f91..1683168 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/build/tmp/compileTestJava/compileTransaction/stash-dir/MemoryMemberRepositoryTest.class.uniqueId0 b/build/tmp/compileTestJava/compileTransaction/stash-dir/MemoryMemberRepositoryTest.class.uniqueId0 new file mode 100644 index 0000000..8d666f5 Binary files /dev/null and b/build/tmp/compileTestJava/compileTransaction/stash-dir/MemoryMemberRepositoryTest.class.uniqueId0 differ diff --git a/build/tmp/compileTestJava/previous-compilation-data.bin b/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..b731ea0 Binary files /dev/null and b/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/src/main/java/com/landvibe/landlog/controller/BlogController.java b/src/main/java/com/landvibe/landlog/controller/BlogController.java new file mode 100644 index 0000000..d8d5900 --- /dev/null +++ b/src/main/java/com/landvibe/landlog/controller/BlogController.java @@ -0,0 +1,94 @@ +package com.landvibe.landlog.controller; + + +import com.landvibe.landlog.domain.Blog; +import com.landvibe.landlog.domain.Member; +import com.landvibe.landlog.repository.BlogRepository; +import com.landvibe.landlog.repository.MemberRepository; +import com.landvibe.landlog.service.BlogService; +import com.landvibe.landlog.service.MemberService; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import java.util.List; +import java.util.Optional; + +@Controller +public class BlogController { + private final MemberService memberService; + private final BlogService blogService; + + public BlogController(MemberService memberService, BlogService blogService){ + this.memberService = memberService; + this.blogService = blogService; + } + + @GetMapping("/blogs/new") + public String createBlog(@RequestParam("creatorId") Long creatorId, Model model) { + Optional user = memberService.findOne(creatorId); + if(!user.isPresent()){ + throw new IllegalArgumentException("존재하지 않는 회원입니다."); + } + model.addAttribute("name", user.get().getName()); + model.addAttribute("creatorId", user.get().getId()); + return "blogs/createBlogForm"; + } + + @PostMapping("/blogs/new") + public String RegisterBlog(@RequestParam("creatorId") Long creatorId, Blog form){ + Blog blog = new Blog(); + blog.setCreatorId(creatorId); + blog.setTitle(form.getTitle()); + blog.setContents(form.getContents()); + blogService.join(blog); + return "redirect:/blogs?creatorId=" + creatorId; + } + + @GetMapping(value="/blogs") + public String blogs(@RequestParam("creatorId") Long creatorId, Model model){ + Optional user = memberService.findOne(creatorId); + if(!user.isPresent()){ + throw new IllegalArgumentException("존재하지 않는 회원입니다."); + } + model.addAttribute("name", user.get().getName()); + model.addAttribute("creatorId", creatorId); + List blogs = blogService.findCreatorBlogs(creatorId); + model.addAttribute("blogs", blogs); + return "blogs/blogList"; + } + + @GetMapping("/blogs/update") + public String findUpdateBlog(@RequestParam("blogId") Long blogId, @RequestParam("creatorId") Long creatorId, Model model){ + Optional user = memberService.findOne(creatorId); + if(!user.isPresent()){ + throw new IllegalArgumentException("존재하지 않는 회원입니다."); + } + List blogs = blogService.findCreatorBlogs(creatorId); + Optional blog = blogService.findOne(blogs, blogId); + + model.addAttribute("blog", blog.get()); + model.addAttribute("creatorId", user.get().getId()); + return "blogs/updateBlogForm"; + } + + @PostMapping("/blogs/update") + public String updateBlog(@RequestParam("creatorId") Long creatorId, Blog blog){ + blogService.update(creatorId, blog.getId(), blog); + return "redirect:/blogs?creatorId=" + creatorId; + } + + @PostMapping("/blogs/delete") + public String deleteBlogFallback(@RequestParam("blogId") Long blogId, @RequestParam("creatorId") Long creatorId) { + Optional user = memberService.findOne(creatorId); + if(!user.isPresent()){ + throw new IllegalArgumentException("존재하지 않는 회원입니다."); + } + blogService.delete(creatorId, blogId); + return "redirect:/blogs?creatorId=" + creatorId; + } +} diff --git a/src/main/java/com/landvibe/landlog/controller/BlogForm.java b/src/main/java/com/landvibe/landlog/controller/BlogForm.java new file mode 100644 index 0000000..ef55a5d --- /dev/null +++ b/src/main/java/com/landvibe/landlog/controller/BlogForm.java @@ -0,0 +1,31 @@ +package com.landvibe.landlog.controller; + +public class BlogForm { + private Long creatorId; + private String title; + private String contents; + + public Long getCreatorId() { + return creatorId; + } + + public void setCreatorId(Long creatorId) { + this.creatorId = creatorId; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setContents(String contents) { + this.contents = contents; + } + + public String getTitle() { + return title; + } + + public String getContents() { + return contents; + } +} diff --git a/src/main/java/com/landvibe/landlog/controller/MemberController.java b/src/main/java/com/landvibe/landlog/controller/MemberController.java index dcc95a3..15996ae 100644 --- a/src/main/java/com/landvibe/landlog/controller/MemberController.java +++ b/src/main/java/com/landvibe/landlog/controller/MemberController.java @@ -5,9 +5,12 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; +import java.util.Optional; @Controller public class MemberController { @@ -17,15 +20,34 @@ public MemberController(MemberService memberService) { this.memberService = memberService; } + @GetMapping(value ="/members/login") + public String login(){ + return "members/loginForm"; + } + + @PostMapping(value = "/members/login") + public String findBlog(@ModelAttribute MemberLoginForm memberLoginForm){ + Member member = new Member(); + member.setEmail(memberLoginForm.getEmail()); + member.setPassword(memberLoginForm.getPassword()); + Optional user = memberService.checkLogin(member); + if(user.isPresent()) { + return "redirect:/blogs?creatorId="+user.get().getId(); + } + return "redirect:/"; + } + @GetMapping(value = "/members/new") public String createForm() { return "members/createMemberForm"; } @PostMapping(value = "/members/new") - public String create(MemberForm form) { + public String create(@ModelAttribute MemberForm form) { Member member = new Member(); member.setName(form.getName()); + member.setEmail(form.getEmail()); + member.setPassword(form.getPassword()); memberService.join(member); return "redirect:/"; } diff --git a/src/main/java/com/landvibe/landlog/controller/MemberForm.java b/src/main/java/com/landvibe/landlog/controller/MemberForm.java index 32d7a01..fb5f3da 100644 --- a/src/main/java/com/landvibe/landlog/controller/MemberForm.java +++ b/src/main/java/com/landvibe/landlog/controller/MemberForm.java @@ -2,12 +2,31 @@ public class MemberForm { private String name; + private String email; + private String password; public String getName() { return name; } + public String getEmail() { + return email; + } + public void setName(String name) { this.name = name; } + + public void setEmail(String email) { + this.email = email; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPassword() { + return password; + } + } diff --git a/src/main/java/com/landvibe/landlog/controller/MemberLoginForm.java b/src/main/java/com/landvibe/landlog/controller/MemberLoginForm.java new file mode 100644 index 0000000..46ce92e --- /dev/null +++ b/src/main/java/com/landvibe/landlog/controller/MemberLoginForm.java @@ -0,0 +1,23 @@ +package com.landvibe.landlog.controller; + +public class MemberLoginForm { + private String email; + private String password; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPassword() { + return password; + } + +} diff --git a/src/main/java/com/landvibe/landlog/domain/Blog.java b/src/main/java/com/landvibe/landlog/domain/Blog.java new file mode 100644 index 0000000..012b059 --- /dev/null +++ b/src/main/java/com/landvibe/landlog/domain/Blog.java @@ -0,0 +1,42 @@ +package com.landvibe.landlog.domain; + +public class Blog { + private Long creatorId; + private Long id; + private String title; + private String contents; + + public Blog(){} + + public Long getCreatorId() { + return creatorId; + } + + public void setCreatorId(Long creatorId) { + this.creatorId = creatorId; + } + + public Long getId() { + return id; + } + + public void setId(Long blogId) { + this.id = blogId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContents() { + return contents; + } + + public void setContents(String content) { + this.contents = content; + } +} diff --git a/src/main/java/com/landvibe/landlog/domain/Member.java b/src/main/java/com/landvibe/landlog/domain/Member.java index acadd35..9cef189 100644 --- a/src/main/java/com/landvibe/landlog/domain/Member.java +++ b/src/main/java/com/landvibe/landlog/domain/Member.java @@ -4,13 +4,17 @@ public class Member { private Long id; private String name; + private String email; + private String password; public Member() { } - public Member(Long id, String name) { + public Member(Long id, String name, String email, String password) { this.id = id; this.name = name; + this.email = email; + this.password = password; } public Long getId() { @@ -28,4 +32,20 @@ public String getName() { public void setName(String name) { this.name = name; } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } } diff --git a/src/main/java/com/landvibe/landlog/repository/BlogRepository.java b/src/main/java/com/landvibe/landlog/repository/BlogRepository.java new file mode 100644 index 0000000..4dc02f3 --- /dev/null +++ b/src/main/java/com/landvibe/landlog/repository/BlogRepository.java @@ -0,0 +1,20 @@ +package com.landvibe.landlog.repository; + +import com.landvibe.landlog.domain.Blog; + +import java.util.List; +import java.util.Optional; + +public interface BlogRepository { + + Blog save(Blog blog); + + List findByCreatorId(Long creatorId); + + Optional findByBlogId(List blogs, Long blogId); + + void updateById(Long creatorId, Long blogId, Blog updatedBlog); + void deleteById(Long creatorId, Long blogId); + + List findAll(); +} diff --git a/src/main/java/com/landvibe/landlog/repository/MemberRepository.java b/src/main/java/com/landvibe/landlog/repository/MemberRepository.java index 0034fe9..eb4126c 100644 --- a/src/main/java/com/landvibe/landlog/repository/MemberRepository.java +++ b/src/main/java/com/landvibe/landlog/repository/MemberRepository.java @@ -13,5 +13,7 @@ public interface MemberRepository { Optional findByName(String name); + Optional findByEmail(String email); + List findAll(); } diff --git a/src/main/java/com/landvibe/landlog/repository/MemoryBlogRepository.java b/src/main/java/com/landvibe/landlog/repository/MemoryBlogRepository.java new file mode 100644 index 0000000..4376a34 --- /dev/null +++ b/src/main/java/com/landvibe/landlog/repository/MemoryBlogRepository.java @@ -0,0 +1,85 @@ +package com.landvibe.landlog.repository; + +import com.landvibe.landlog.domain.Blog; +import org.springframework.stereotype.Repository; + +import java.util.*; + +@Repository +public class MemoryBlogRepository implements BlogRepository { + + private Map store = new HashMap(); + private static long sequence = 0L; + + @Override + public Blog save(Blog blog) { + if(blog.getId()==null) {blog.setId(++sequence);} + store.put(blog.getId(), blog); + return blog; + } + + @Override + public List findByCreatorId(Long creatorId) { + List blogs = new ArrayList<>(); + for(Blog blog : store.values()){ + if(blog.getCreatorId().equals(creatorId)){ + blogs.add(blog); + } + } + return blogs; + } + + @Override + public Optional findByBlogId(List blogs, Long blogId) { + for(Blog blog : blogs){ + if(blog.getId().equals(blogId)){ + return Optional.of(blog); + } + } + return Optional.empty(); + } + + @Override + public void updateById(Long creatorId, Long blogId, Blog updatedBlog){ + List blogs = findByCreatorId(creatorId); + Blog blog = findByBlogId(blogs, blogId).get(); + blog.setTitle(updatedBlog.getTitle()); + blog.setContents(updatedBlog.getContents()); + save(blog); + return; + /* + for(Blog blog : blogs){ + if(blog.getId().equals(blogId)){ + blog.setTitle(updatedBlog.getTitle()); + blog.setContents(updatedBlog.getContents()); + save(blog); + return; + } + } + throw new IllegalStateException("존재하지 않는 게시글입니다.");*/ + + } + + @Override + public void deleteById(Long creatorId, Long blogId) { + List blogs = findByCreatorId(creatorId); + Blog blog = findByBlogId(blogs, blogId).get(); + store.remove(blogId); +/* for(Blog blog : blogs){ + if(blog.getId().equals(blogId)){ + store.remove(blogId); + return; + } + } + throw new IllegalStateException("존재하지 않는 게시글입니다.");*/ + } + + @Override + public List findAll() { + return new ArrayList(store.values()); + } + + public void clearStore() { + store.clear(); + } +} diff --git a/src/main/java/com/landvibe/landlog/repository/MemoryMemberRepository.java b/src/main/java/com/landvibe/landlog/repository/MemoryMemberRepository.java index d84e250..99cebbf 100644 --- a/src/main/java/com/landvibe/landlog/repository/MemoryMemberRepository.java +++ b/src/main/java/com/landvibe/landlog/repository/MemoryMemberRepository.java @@ -30,6 +30,13 @@ public Optional findByName(String name) { .findAny(); } + @Override + public Optional findByEmail(String email) { + return store.values().stream() + .filter(member -> member.getEmail().equals(email)) + .findAny(); + } + @Override public List findAll() { return new ArrayList<>(store.values()); diff --git a/src/main/java/com/landvibe/landlog/service/BlogService.java b/src/main/java/com/landvibe/landlog/service/BlogService.java new file mode 100644 index 0000000..babb322 --- /dev/null +++ b/src/main/java/com/landvibe/landlog/service/BlogService.java @@ -0,0 +1,41 @@ +package com.landvibe.landlog.service; + +import com.landvibe.landlog.domain.Blog; +import com.landvibe.landlog.domain.Member; +import com.landvibe.landlog.repository.BlogRepository; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +public class BlogService { + private final BlogRepository blogRepository; + + public BlogService(BlogRepository blogRepository) { + this.blogRepository = blogRepository; + } + + public Long join(Blog blog) { + blogRepository.save(blog); + return blog.getId(); + } + + public void update(Long creatorId, Long blogId, Blog updatedBlog){ + blogRepository.updateById(creatorId, blogId, updatedBlog); + } + + public void delete(Long creatorId, Long blogId){ + blogRepository.deleteById(creatorId, blogId); + } + + public List findMembers() { + return blogRepository.findAll(); + } + + public List findCreatorBlogs(Long creatorId){ return blogRepository.findByCreatorId(creatorId);} + + public Optional findOne(List blogs, Long blogId) { + return blogRepository.findByBlogId(blogs, blogId); + } +} diff --git a/src/main/java/com/landvibe/landlog/service/MemberService.java b/src/main/java/com/landvibe/landlog/service/MemberService.java index c4ac876..98645aa 100644 --- a/src/main/java/com/landvibe/landlog/service/MemberService.java +++ b/src/main/java/com/landvibe/landlog/service/MemberService.java @@ -17,10 +17,25 @@ public MemberService(MemberRepository memberRepository) { public Long join(Member member) { validateDuplicateMember(member); //중복 회원 검증 + validateDuplicateEmail(member); //중복 이메일 검증 memberRepository.save(member); return member.getId(); } + public Optional checkLogin(Member member){ + Optional user = findOne(member.getEmail()); + if(user.isPresent()){ + if(user.get().getPassword().equals(member.getPassword())){ + return user; + }else { + return Optional.empty(); + } + } + else { + return Optional.empty(); + } + } + private void validateDuplicateMember(Member member) { memberRepository.findByName(member.getName()) .ifPresent(m -> { @@ -28,6 +43,13 @@ private void validateDuplicateMember(Member member) { }); } + private void validateDuplicateEmail(Member member) { + memberRepository.findByEmail(member.getEmail()) + .ifPresent(m -> { + throw new IllegalStateException("이미 사용되고 있는 이메일입니다."); + }); + } + public List findMembers() { return memberRepository.findAll(); } @@ -35,4 +57,9 @@ public List findMembers() { public Optional findOne(Long memberId) { return memberRepository.findById(memberId); } + + public Optional findOne(String email){ + return memberRepository.findByEmail(email); + } + } diff --git a/src/main/resources/templates/blogs/blogList.html b/src/main/resources/templates/blogs/blogList.html new file mode 100644 index 0000000..63e5e5e --- /dev/null +++ b/src/main/resources/templates/blogs/blogList.html @@ -0,0 +1,37 @@ + + + +
+
+

의 블로그

+

+ 생성 +

+ + + + + + + + + + + + + + + + + + + +
#제목내용
수정 +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/blogs/createBlogForm.html b/src/main/resources/templates/blogs/createBlogForm.html new file mode 100644 index 0000000..1e611fe --- /dev/null +++ b/src/main/resources/templates/blogs/createBlogForm.html @@ -0,0 +1,20 @@ + + + +
+

의 블로그

+
+ +
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/blogs/updateBlogForm.html b/src/main/resources/templates/blogs/updateBlogForm.html new file mode 100644 index 0000000..5f4e1ca --- /dev/null +++ b/src/main/resources/templates/blogs/updateBlogForm.html @@ -0,0 +1,21 @@ + + + +
+

의 블로그

+
+ + +
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html index 109d59d..15a4e6f 100644 --- a/src/main/resources/templates/home.html +++ b/src/main/resources/templates/home.html @@ -6,6 +6,7 @@

Hello Spring

회원 기능

+ 로그인 회원 가입 회원 목록

diff --git a/src/main/resources/templates/members/createMemberForm.html b/src/main/resources/templates/members/createMemberForm.html index c0353f2..54898ae 100644 --- a/src/main/resources/templates/members/createMemberForm.html +++ b/src/main/resources/templates/members/createMemberForm.html @@ -7,6 +7,14 @@ +
+ + +
+
+ + +
diff --git a/src/main/resources/templates/members/loginForm.html b/src/main/resources/templates/members/loginForm.html new file mode 100644 index 0000000..405f17a --- /dev/null +++ b/src/main/resources/templates/members/loginForm.html @@ -0,0 +1,18 @@ + + + +
+
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/test/java/com/landvibe/landlog/repository/MemoryMemberRepositoryTest.java b/src/test/java/com/landvibe/landlog/repository/MemoryMemberRepositoryTest.java index 2d2deef..3880a1e 100644 --- a/src/test/java/com/landvibe/landlog/repository/MemoryMemberRepositoryTest.java +++ b/src/test/java/com/landvibe/landlog/repository/MemoryMemberRepositoryTest.java @@ -22,6 +22,8 @@ void save() { //given Member member = new Member(); member.setName("spring"); + member.setEmail("spring@gmail.com"); + member.setPassword("12345"); //when repository.save(member); @@ -31,6 +33,20 @@ void save() { assertThat(result).isEqualTo(member); } + @Test + public void findById(){ + //given + Member member = new Member(); + member.setName("spring"); + repository.save(member); + + //when + Member result = repository.findById(member.getId()).get(); + + //then + assertThat(result).isEqualTo(member); + } + @Test public void findByName() { //given @@ -48,14 +64,35 @@ public void findByName() { assertThat(result).isEqualTo(member1); } + @Test + public void findByEmail() { + //given + Member member1 = new Member(); + member1.setEmail("spring1@gmail.com"); + repository.save(member1); + Member member2 = new Member(); + member2.setEmail("spring2@gmail.com"); + repository.save(member2); + + //when + Member result = repository.findByEmail("spring1@gmail.com").get(); + + //then + assertThat(result).isEqualTo(member1); + } + @Test public void findAll() { //given Member member1 = new Member(); member1.setName("spring1"); + member1.setEmail("spring1@gmail.com"); + member1.setPassword("12345"); repository.save(member1); Member member2 = new Member(); member2.setName("spring2"); + member2.setEmail("spring2@gmail.com"); + member2.setPassword("12345"); repository.save(member2); //when diff --git a/src/test/java/com/landvibe/landlog/service/MemberServiceTest.java b/src/test/java/com/landvibe/landlog/service/MemberServiceTest.java index 8bca94f..f81c927 100644 --- a/src/test/java/com/landvibe/landlog/service/MemberServiceTest.java +++ b/src/test/java/com/landvibe/landlog/service/MemberServiceTest.java @@ -31,23 +31,47 @@ public void afterEach() { //Given Member member = new Member(); member.setName("hello"); + member.setEmail("hello@gmail.com"); + member.setPassword("12345"); //When Long saveId = memberService.join(member); //Then - Member findMember = memberRepository.findById(saveId).get(); - assertEquals(member.getName(), findMember.getName()); + Member findMember1 = memberRepository.findById(saveId).get(); + assertEquals(member.getName(), findMember1.getName()); } @Test public void 중복_회원_예외() throws Exception { //Given Member member1 = new Member(); member1.setName("spring"); + member1.setEmail("abc123@gmail.com"); + member1.setPassword("12345"); Member member2 = new Member(); member2.setName("spring"); + member2.setEmail("abc123@naver.com"); + member2.setPassword("12345"); //When memberService.join(member1); IllegalStateException e = assertThrows(IllegalStateException.class, () -> memberService.join(member2));//예외가 발생해야 한다. assertThat(e.getMessage()).isEqualTo("이미 존재하는 회원입니다."); } + + @Test + public void 중복_이메일_예외() throws Exception{ + //Given + Member member1 = new Member(); + member1.setName("spring1"); + member1.setEmail("abc123@gmail.com"); + member1.setPassword("12345"); + Member member2 = new Member(); + member1.setName("spring2"); + member2.setEmail("abc123@gmail.com"); + member2.setPassword("12345"); + //When + memberService.join(member1); + IllegalStateException e = assertThrows(IllegalStateException.class, + () -> memberService.join(member2)); //예외가 발생해야 한다. + assertThat(e.getMessage()).isEqualTo("이미 사용되고 있는 이메일입니다."); + } } \ No newline at end of file