diff --git a/src/main/java/net/slipp/domain/qna/QnaSpecifications.java b/src/main/java/net/slipp/domain/qna/QnaSpecifications.java index 432a0c52..2de23d6e 100644 --- a/src/main/java/net/slipp/domain/qna/QnaSpecifications.java +++ b/src/main/java/net/slipp/domain/qna/QnaSpecifications.java @@ -1,14 +1,19 @@ package net.slipp.domain.qna; +import static org.springframework.data.jpa.domain.Specifications.*; + import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; +import net.slipp.domain.user.SocialUser; + import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.jpa.domain.Specifications; public class QnaSpecifications { - public static Specification equalsIsDelete(final boolean isDeleted) { + public static Specification equalsIsDeleteToQuestion(final boolean isDeleted) { return new Specification() { @Override public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) { @@ -16,4 +21,31 @@ public Predicate toPredicate(Root root, CriteriaQuery query, Criter } }; } + + private static Specification equalsWriterIdToQuestion(final SocialUser writer) { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) { + return cb.equal(root.get(Question_.writer), writer); + } + }; + } + + public static Specification findQuestions(final SocialUser writer, final boolean isDeleted) { + if (writer == null) { + return equalsIsDeleteToQuestion(isDeleted); + } + + Specifications specs = where(equalsWriterIdToQuestion(writer)); + return specs.and(equalsIsDeleteToQuestion(isDeleted)); + } + + public static Specification equalsWriterIdToAnswer(final SocialUser writer) { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) { + return cb.equal(root.get(Answer_.writer), writer); + } + }; + } } diff --git a/src/main/java/net/slipp/domain/user/SocialUser.java b/src/main/java/net/slipp/domain/user/SocialUser.java index c1160d1b..b2730a53 100644 --- a/src/main/java/net/slipp/domain/user/SocialUser.java +++ b/src/main/java/net/slipp/domain/user/SocialUser.java @@ -237,6 +237,10 @@ public boolean isGuest() { return true; } } + + public String getUrl() { + return String.format("/users/%d/%s", id, userId); + } @Override public String toString() { diff --git a/src/main/java/net/slipp/service/qna/QnaService.java b/src/main/java/net/slipp/service/qna/QnaService.java index 0401202d..709624a2 100644 --- a/src/main/java/net/slipp/service/qna/QnaService.java +++ b/src/main/java/net/slipp/service/qna/QnaService.java @@ -14,6 +14,7 @@ import net.slipp.repository.qna.QuestionRepository; import net.slipp.service.rank.ScoreLikeService; import net.slipp.service.tag.TagService; +import net.slipp.service.user.SocialUserService; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -27,129 +28,146 @@ @Service("qnaService") @Transactional public class QnaService { - @Resource(name = "questionRepository") - private QuestionRepository questionRepository; - - @Resource(name = "answerRepository") - private AnswerRepository answerRepository; - - @Resource(name = "tagService") - private TagService tagService; - - @Resource(name = "notificationService") - private NotificationService notificationService; - - @Resource(name = "scoreLikeService") - private ScoreLikeService scoreLikeService; - - @Resource(name = "facebookService") - private FacebookService facebookService; - - public Question createQuestion(final SocialUser loginUser, QuestionDto questionDto) { - Assert.notNull(loginUser, "loginUser should be not null!"); - Assert.notNull(questionDto, "question should be not null!"); - - Set tags = tagService.processTags(questionDto.getPlainTags()); - - Question newQuestion = new Question(loginUser, questionDto.getTitle(), questionDto.getContents(), tags); - final Question savedQuestion = questionRepository.save(newQuestion); - - if (questionDto.isConnected()) { - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { - public void afterCommit() { - facebookService.sendToQuestionMessage(loginUser, savedQuestion.getQuestionId()); - } - }); - } - return savedQuestion; - } - - public Question updateQuestion(SocialUser loginUser, QuestionDto questionDto) { - Assert.notNull(loginUser, "loginUser should be not null!"); - Assert.notNull(questionDto, "question should be not null!"); - - Question question = questionRepository.findOne(questionDto.getQuestionId()); - - Set tags = tagService.processTags(questionDto.getPlainTags()); - question.update(loginUser, questionDto.getTitle(), questionDto.getContents(), tags); - return question; - } - - public void deleteQuestion(SocialUser loginUser, Long questionId) { - Assert.notNull(loginUser, "loginUser should be not null!"); - Assert.notNull(questionId, "questionId should be not null!"); - - Question question = questionRepository.findOne(questionId); - question.delete(loginUser); - } - - public Question showQuestion(Long id) { - questionRepository.updateShowCount(id); - return questionRepository.findOne(id); - } - - public Page findsByTag(String name, Pageable pageable) { - return questionRepository.findsByTag(name, pageable); - } - - public Page findsQuestion(Pageable pageable) { - return questionRepository.findAll(QnaSpecifications.equalsIsDelete(false), pageable); - } - - public Question findByQuestionId(Long id) { - return questionRepository.findOne(id); - } - - public Answer findAnswerById(Long answerId) { - return answerRepository.findOne(answerId); - } - - public void createAnswer(final SocialUser loginUser, Long questionId, final Answer answer) { - final Question question = questionRepository.findOne(questionId); - answer.writedBy(loginUser); - answer.answerTo(question); - final Answer savedAnswer = answerRepository.save(answer); - - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { - public void afterCommit() { - notificationService.notifyToSlipp(loginUser, savedAnswer.getAnswerId()); - notificationService.notifyToFacebook(loginUser, savedAnswer.getAnswerId()); - if (answer.isConnected()) { - facebookService.sendToAnswerMessage(loginUser, savedAnswer.getAnswerId()); - } - } - }); - } - - public void updateAnswer(SocialUser loginUser, Answer answerDto) { - Answer answer = answerRepository.findOne(answerDto.getAnswerId()); - if (!answer.isWritedBy(loginUser)) { - throw new AccessDeniedException(loginUser + " is not owner!"); - } - answer.updateAnswer(answerDto); - } - - public void deleteAnswer(SocialUser loginUser, Long questionId, Long answerId) { - Assert.notNull(loginUser, "loginUser should be not null!"); - Assert.notNull(questionId, "questionId should be not null!"); - Assert.notNull(answerId, "answerId should be not null!"); - - Answer answer = answerRepository.findOne(answerId); - if (!answer.isWritedBy(loginUser)) { - throw new AccessDeniedException(loginUser + " is not owner!"); - } - answerRepository.delete(answer); - Question question = questionRepository.findOne(questionId); - question.deAnswered(answer); - } - - public void likeAnswer(SocialUser loginUser, Long answerId) { - if (!scoreLikeService.alreadyLikedAnswer(answerId, loginUser.getId())) { - scoreLikeService.saveLikeAnswer(answerId, loginUser.getId()); - Answer answer = answerRepository.findOne(answerId); - answer.upRank(); - answerRepository.save(answer); - } - } + @Resource(name = "questionRepository") + private QuestionRepository questionRepository; + + @Resource(name = "answerRepository") + private AnswerRepository answerRepository; + + @Resource(name = "tagService") + private TagService tagService; + + @Resource(name = "notificationService") + private NotificationService notificationService; + + @Resource(name = "scoreLikeService") + private ScoreLikeService scoreLikeService; + + @Resource(name = "facebookService") + private FacebookService facebookService; + + @Resource(name = "socialUserService") + private SocialUserService socialUserService; + + public Question createQuestion(final SocialUser loginUser, QuestionDto questionDto) { + Assert.notNull(loginUser, "loginUser should be not null!"); + Assert.notNull(questionDto, "question should be not null!"); + + Set tags = tagService.processTags(questionDto.getPlainTags()); + + Question newQuestion = new Question(loginUser, questionDto.getTitle(), questionDto.getContents(), tags); + final Question savedQuestion = questionRepository.save(newQuestion); + + if (questionDto.isConnected()) { + TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + public void afterCommit() { + facebookService.sendToQuestionMessage(loginUser, savedQuestion.getQuestionId()); + } + }); + } + return savedQuestion; + } + + public Question updateQuestion(SocialUser loginUser, QuestionDto questionDto) { + Assert.notNull(loginUser, "loginUser should be not null!"); + Assert.notNull(questionDto, "question should be not null!"); + + Question question = questionRepository.findOne(questionDto.getQuestionId()); + + Set tags = tagService.processTags(questionDto.getPlainTags()); + question.update(loginUser, questionDto.getTitle(), questionDto.getContents(), tags); + return question; + } + + public void deleteQuestion(SocialUser loginUser, Long questionId) { + Assert.notNull(loginUser, "loginUser should be not null!"); + Assert.notNull(questionId, "questionId should be not null!"); + + Question question = questionRepository.findOne(questionId); + question.delete(loginUser); + } + + public Question showQuestion(Long id) { + questionRepository.updateShowCount(id); + return questionRepository.findOne(id); + } + + public Page findsByTag(String name, Pageable pageable) { + return questionRepository.findsByTag(name, pageable); + } + + public Page findsQuestion(Pageable pageable) { + return questionRepository.findAll(QnaSpecifications.equalsIsDeleteToQuestion(false), pageable); + } + + public Page findsQuestionByWriter(Long writerId, Pageable pageable) { + if (writerId == null) { + return questionRepository.findAll(QnaSpecifications.equalsIsDeleteToQuestion(false), pageable); + } + + SocialUser writer = socialUserService.findById(writerId); + return questionRepository.findAll(QnaSpecifications.findQuestions(writer, false), pageable); + } + + public Question findByQuestionId(Long id) { + return questionRepository.findOne(id); + } + + public Answer findAnswerById(Long answerId) { + return answerRepository.findOne(answerId); + } + + public Page findsAnswerByWriter(Long writerId, Pageable pageable) { + SocialUser writer = socialUserService.findById(writerId); + return answerRepository.findAll(QnaSpecifications.equalsWriterIdToAnswer(writer), pageable); + } + + public void createAnswer(final SocialUser loginUser, Long questionId, final Answer answer) { + final Question question = questionRepository.findOne(questionId); + answer.writedBy(loginUser); + answer.answerTo(question); + final Answer savedAnswer = answerRepository.save(answer); + + TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + public void afterCommit() { + notificationService.notifyToSlipp(loginUser, savedAnswer.getAnswerId()); + notificationService.notifyToFacebook(loginUser, savedAnswer.getAnswerId()); + if (answer.isConnected()) { + facebookService.sendToAnswerMessage(loginUser, savedAnswer.getAnswerId()); + } + } + }); + } + + public void updateAnswer(SocialUser loginUser, Answer answerDto) { + Answer answer = answerRepository.findOne(answerDto.getAnswerId()); + if (!answer.isWritedBy(loginUser)) { + throw new AccessDeniedException(loginUser + " is not owner!"); + } + answer.updateAnswer(answerDto); + } + + public void deleteAnswer(SocialUser loginUser, Long questionId, Long answerId) { + Assert.notNull(loginUser, "loginUser should be not null!"); + Assert.notNull(questionId, "questionId should be not null!"); + Assert.notNull(answerId, "answerId should be not null!"); + + Answer answer = answerRepository.findOne(answerId); + if (!answer.isWritedBy(loginUser)) { + throw new AccessDeniedException(loginUser + " is not owner!"); + } + answerRepository.delete(answer); + Question question = questionRepository.findOne(questionId); + question.deAnswered(answer); + } + + public void likeAnswer(SocialUser loginUser, Long answerId) { + if (!scoreLikeService.alreadyLikedAnswer(answerId, loginUser.getId())) { + scoreLikeService.saveLikeAnswer(answerId, loginUser.getId()); + Answer answer = answerRepository.findOne(answerId); + answer.upRank(); + answerRepository.save(answer); + } + } } diff --git a/src/main/java/net/slipp/service/user/SocialUserService.java b/src/main/java/net/slipp/service/user/SocialUserService.java index ab5dfb5d..9f1ac164 100644 --- a/src/main/java/net/slipp/service/user/SocialUserService.java +++ b/src/main/java/net/slipp/service/user/SocialUserService.java @@ -36,7 +36,7 @@ public class SocialUserService { @Resource(name = "mailService") private MailService mailService; - public void createNewSocialUser(String userId, Connection connection) throws ExistedUserException { + public void createNewSocialUser(String userId, String nickname, Connection connection) throws ExistedUserException { Assert.notNull(userId, "userId can't be null!"); Assert.notNull(connection, "connection can't be null!"); @@ -46,6 +46,9 @@ public void createNewSocialUser(String userId, Connection connection) throws } connectionRepository.addConnection(connection); + + SocialUser socialUser = findByUserId(userId); + socialUser.setDisplayName(nickname); } private boolean isUserIdAvailable(String userId) { diff --git a/src/main/java/net/slipp/social/security/SignUpForm.java b/src/main/java/net/slipp/social/security/SignUpForm.java index 034700e8..b43dac4a 100644 --- a/src/main/java/net/slipp/social/security/SignUpForm.java +++ b/src/main/java/net/slipp/social/security/SignUpForm.java @@ -5,25 +5,35 @@ * */ public class SignUpForm { - private String username; + private String userId; + + private String nickName; public SignUpForm() { } - public SignUpForm(String username) { - this.username = username; + public SignUpForm(String nickname) { + this.nickName = nickname; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; } - public String getUsername() { - return username; + public String getNickName() { + return nickName; } - public void setUsername(String username) { - this.username = username; + public void setNickName(String nickname) { + this.nickName = nickname; } @Override public String toString() { - return "SignUpForm [username=" + username + "]"; + return "SignUpForm [userId=" + userId + ", nickname=" + nickName + "]"; } } diff --git a/src/main/java/net/slipp/social/security/SlippSecuritySignUpController.java b/src/main/java/net/slipp/social/security/SlippSecuritySignUpController.java index b8167d9b..0ae2715a 100644 --- a/src/main/java/net/slipp/social/security/SlippSecuritySignUpController.java +++ b/src/main/java/net/slipp/social/security/SlippSecuritySignUpController.java @@ -45,11 +45,11 @@ public String signUpForm(ServletWebRequest request, Model model) { public String signUpSubmit(ServletWebRequest request, SignUpForm signUpForm, BindingResult result) { Connection connection = ProviderSignInUtils.getConnection(request); try { - socialUserService.createNewSocialUser(signUpForm.getUsername(), connection); - signInAdapter.signIn(signUpForm.getUsername(), connection, request); + socialUserService.createNewSocialUser(signUpForm.getUserId(), signUpForm.getNickName(), connection); + signInAdapter.signIn(signUpForm.getUserId(), connection, request); return "redirect:" + authenticateUrl; } catch (ExistedUserException e) { - result.addError(new FieldError("signUpForm", "username", signUpForm.getUsername() + result.addError(new FieldError("signUpForm", "userId", signUpForm.getUserId() + "은 이미 존재하는 아이디입니다. 다른 아이디를 선택해주세요.")); return "users/signUpForm"; } diff --git a/src/main/java/net/slipp/web/HomeController.java b/src/main/java/net/slipp/web/HomeController.java index 52154c2e..54e14787 100644 --- a/src/main/java/net/slipp/web/HomeController.java +++ b/src/main/java/net/slipp/web/HomeController.java @@ -1,6 +1,6 @@ package net.slipp.web; -import static net.slipp.web.QuestionPageableHelper.*; +import static net.slipp.web.QnAPageableHelper.*; import java.util.Date; import java.util.List; @@ -39,7 +39,7 @@ public String home(Model model) { if (isProductionMode()) { model.addAttribute("pages", wikiService.findWikiPages()); } - model.addAttribute("questions", qnaService.findsQuestion(createPageable(DEFAULT_PAGE_NO, DEFAULT_PAGE_SIZE))); + model.addAttribute("questions", qnaService.findsQuestion(createPageableByQuestionUpdatedDate(DEFAULT_PAGE_NO, DEFAULT_PAGE_SIZE))); model.addAttribute("tags", tagService.findPooledTags()); return "index"; } diff --git a/src/main/java/net/slipp/web/QnAPageableHelper.java b/src/main/java/net/slipp/web/QnAPageableHelper.java new file mode 100644 index 00000000..d16fc14a --- /dev/null +++ b/src/main/java/net/slipp/web/QnAPageableHelper.java @@ -0,0 +1,30 @@ +package net.slipp.web; + +import net.slipp.domain.qna.Answer_; +import net.slipp.domain.qna.Question_; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; + +public class QnAPageableHelper { + public static final int DEFAULT_PAGE_NO = 1; + + public static Pageable createPageableByQuestionUpdatedDate(Integer currentPage, Integer pageSize) { + Sort sort = new Sort(Direction.DESC, Question_.updatedDate.getName()); + return new PageRequest(currentPage - 1, pageSize, sort); + } + + public static Pageable createPageableByAnswerCreatedDate(Integer currentPage, Integer pageSize) { + Sort sort = new Sort(Direction.DESC, Answer_.createdDate.getName()); + return new PageRequest(currentPage - 1, pageSize, sort); + } + + public static Integer revisedPage(Integer page) { + if (page == null) { + page = DEFAULT_PAGE_NO; + } + return page; + } +} diff --git a/src/main/java/net/slipp/web/QuestionPageableHelper.java b/src/main/java/net/slipp/web/QuestionPageableHelper.java deleted file mode 100644 index 6fee1178..00000000 --- a/src/main/java/net/slipp/web/QuestionPageableHelper.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.slipp.web; - -import net.slipp.domain.qna.Question_; - -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Direction; - -public class QuestionPageableHelper { - public static Pageable createPageable(Integer currentPage, Integer pageSize) { - Sort sort = new Sort(Direction.DESC, Question_.updatedDate.getName()); - return new PageRequest(currentPage - 1, pageSize, sort); - } -} diff --git a/src/main/java/net/slipp/web/qna/QuestionController.java b/src/main/java/net/slipp/web/qna/QuestionController.java index fc063b24..4ba03458 100644 --- a/src/main/java/net/slipp/web/qna/QuestionController.java +++ b/src/main/java/net/slipp/web/qna/QuestionController.java @@ -1,6 +1,6 @@ package net.slipp.web.qna; -import static net.slipp.web.QuestionPageableHelper.*; +import static net.slipp.web.QnAPageableHelper.*; import javax.annotation.Resource; @@ -26,7 +26,6 @@ public class QuestionController { private static final Logger logger = LoggerFactory.getLogger(QuestionController.class); - private static final int DEFAULT_PAGE_NO = 1; private static final int DEFAULT_PAGE_SIZE = 15; @Resource(name = "qnaService") @@ -39,7 +38,7 @@ public class QuestionController { public String index(Integer page, Model model) { page = revisedPage(page); logger.debug("currentPage : {}", page); - model.addAttribute("questions", qnaService.findsQuestion(createPageable(page, DEFAULT_PAGE_SIZE))); + model.addAttribute("questions", qnaService.findsQuestion(createPageableByQuestionUpdatedDate(page, DEFAULT_PAGE_SIZE))); model.addAttribute("tags", tagService.findPooledTags()); return "qna/list"; } @@ -96,15 +95,8 @@ public String delete(@LoginUser SocialUser loginUser, @PathVariable Long id) { public String listByTagged(@PathVariable String name, Integer page, Model model) { page = revisedPage(page); model.addAttribute("currentTag", tagService.findTagByName(name)); - model.addAttribute("questions", qnaService.findsByTag(name, createPageable(page, DEFAULT_PAGE_SIZE))); + model.addAttribute("questions", qnaService.findsByTag(name, createPageableByQuestionUpdatedDate(page, DEFAULT_PAGE_SIZE))); model.addAttribute("tags", tagService.findPooledTags()); return "qna/list"; } - - private Integer revisedPage(Integer page) { - if (page == null) { - page = DEFAULT_PAGE_NO; - } - return page; - } } diff --git a/src/main/java/net/slipp/web/user/UsersController.java b/src/main/java/net/slipp/web/user/UsersController.java index 07942471..149a09ed 100644 --- a/src/main/java/net/slipp/web/user/UsersController.java +++ b/src/main/java/net/slipp/web/user/UsersController.java @@ -1,11 +1,15 @@ package net.slipp.web.user; +import static net.slipp.web.QnAPageableHelper.*; + + import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.slipp.domain.user.PasswordDto; import net.slipp.domain.user.SocialUser; +import net.slipp.service.qna.QnaService; import net.slipp.service.user.SocialUserService; import net.slipp.social.security.AutoLoginAuthenticator; import net.slipp.support.web.argumentresolver.LoginUser; @@ -21,11 +25,17 @@ @Controller @RequestMapping("/users") public class UsersController { + private static final int DEFAULT_SUMMARY_PAGE_SIZE = 5; + private static final int DEFAULT_PAGE_SIZE = 15; + @Resource(name = "socialUserService") private SocialUserService userService; @Resource(name = "autoLoginAuthenticator") private AutoLoginAuthenticator autoLoginAuthenticator; + + @Resource(name = "qnaService") + private QnaService qnaService; @RequestMapping("/login") public String login(Model model) { @@ -44,19 +54,37 @@ public String create(UserForm user, HttpServletRequest request, HttpServletRespo public String logout() { return "users/fblogout"; } - + @RequestMapping("/{id}") public String profileById(@PathVariable Long id) throws Exception { SocialUser socialUser = userService.findById(id); return String.format("redirect:/users/%d/%s", id, socialUser.getUserId()); } - + @RequestMapping("/{id}/{userId}") public String profile(@PathVariable Long id, @PathVariable String userId, Model model) throws Exception { + model.addAttribute("questions", qnaService.findsQuestionByWriter(id, createPageableByQuestionUpdatedDate(DEFAULT_PAGE_NO, DEFAULT_SUMMARY_PAGE_SIZE))); + model.addAttribute("answers", qnaService.findsAnswerByWriter(id, createPageableByAnswerCreatedDate(DEFAULT_PAGE_NO, DEFAULT_SUMMARY_PAGE_SIZE))); model.addAttribute("socialUser", userService.findById(id)); return "users/profile"; } + + @RequestMapping("/{id}/{userId}/questions") + public String questions(@PathVariable Long id, Integer page, Model model) throws Exception { + page = revisedPage(page); + model.addAttribute("questions", qnaService.findsQuestionByWriter(id, createPageableByQuestionUpdatedDate(page, DEFAULT_PAGE_SIZE))); + model.addAttribute("socialUser", userService.findById(id)); + return "users/questions"; + } + @RequestMapping("/{id}/{userId}/answers") + public String answers(@PathVariable Long id, Integer page, Model model) throws Exception { + page = revisedPage(page); + model.addAttribute("answers", qnaService.findsAnswerByWriter(id, createPageableByAnswerCreatedDate(page, DEFAULT_PAGE_SIZE))); + model.addAttribute("socialUser", userService.findById(id)); + return "users/answers"; + } + @RequestMapping("/changepassword/{id}") public String changePasswordForm(@LoginUser SocialUser loginUser, @PathVariable Long id, Model model) throws Exception { diff --git a/src/main/resources-development/META-INF/persistence.xml b/src/main/resources-development/META-INF/persistence.xml index cb9af8d5..4f8d1359 100644 --- a/src/main/resources-development/META-INF/persistence.xml +++ b/src/main/resources-development/META-INF/persistence.xml @@ -6,8 +6,8 @@ org.hibernate.ejb.HibernatePersistence - - + + diff --git a/src/test/java/net/slipp/service/user/SocialUserServiceTest.java b/src/test/java/net/slipp/service/user/SocialUserServiceTest.java index 4565c8e0..1d79306e 100644 --- a/src/test/java/net/slipp/service/user/SocialUserServiceTest.java +++ b/src/test/java/net/slipp/service/user/SocialUserServiceTest.java @@ -52,11 +52,12 @@ public void setup() { @Ignore @Test public void createNewSocialUser_availableUserId() throws Exception { String userId = "userId"; + String nickName = "nickName"; when(usersConnectionRepository.createConnectionRepository(userId)).thenReturn(connectionRepository); MultiValueMap> connections = new LinkedMultiValueMap>(); when(connectionRepository.findAllConnections()).thenReturn(connections); - dut.createNewSocialUser(userId, connection); + dut.createNewSocialUser(userId, nickName, connection); verify(connectionRepository).addConnection(connection); } @@ -64,12 +65,13 @@ public void createNewSocialUser_availableUserId() throws Exception { @Ignore @Test(expected=ExistedUserException.class) public void createNewSocialUser_notAvailableUserId() throws Exception { String userId = "userId"; + String nickName = "nickName"; when(usersConnectionRepository.createConnectionRepository(userId)).thenReturn(connectionRepository); MultiValueMap> connections = new LinkedMultiValueMap>(); connections.add("facebook", connection); when(connectionRepository.findAllConnections()).thenReturn(connections); - dut.createNewSocialUser(userId, connection); + dut.createNewSocialUser(userId, nickName, connection); } @Test diff --git a/src/test/java/net/slipp/social/security/SignUpFormTest.java b/src/test/java/net/slipp/social/security/SignUpFormTest.java deleted file mode 100644 index 3ee6e86f..00000000 --- a/src/test/java/net/slipp/social/security/SignUpFormTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.slipp.social.security; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class SignUpFormTest { - @Test - public void getUsername() { - String username = "username"; - SignUpForm signUpForm = new SignUpForm(username); - assertThat(signUpForm.getUsername(), is(username)); - } -} diff --git a/webapp/WEB-INF/jsp/decorators/default.jsp b/webapp/WEB-INF/jsp/decorators/default.jsp index 718ae759..d0bc524d 100644 --- a/webapp/WEB-INF/jsp/decorators/default.jsp +++ b/webapp/WEB-INF/jsp/decorators/default.jsp @@ -56,13 +56,13 @@