• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account Log out
  • Favorite
  • Project
  • Recent History
Loading...
  • Log in
  • Sign up
kadrians / Testing_for_YONA star
  • Project homeH
  • CodeC
  • IssueI 1
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 2
  • Files
  • Commit
  • Branches
Testing_for_YONAsourcetestmodelssupportReviewSearchConditionTest.java
Download as .zip file
File name
Commit message
Commit date
bin
Yona 1.16.0 Upload
02-04
lib
Yona 1.16.0 Upload
02-04
share/doc/api
Yona 1.16.0 Upload
02-04
source
Source Code Upload
02-04
README.md
Yona 1.16.0 Upload
02-04
File name
Commit message
Commit date
app
Source Code Upload
02-04
conf
Source Code Upload
02-04
docs
Source Code Upload
02-04
lib
Source Code Upload
02-04
project
Source Code Upload
02-04
public
Source Code Upload
02-04
support-script
Source Code Upload
02-04
test
Source Code Upload
02-04
.gitignore
Source Code Upload
02-04
.mailmap
Source Code Upload
02-04
.travis.yml
Source Code Upload
02-04
AUTHORS
Source Code Upload
02-04
LICENSE
Source Code Upload
02-04
NOTICE
Source Code Upload
02-04
README.md
Source Code Upload
02-04
build.sbt
Source Code Upload
02-04
dev.sh
Source Code Upload
02-04
dist.sh
Source Code Upload
02-04
is-alive-bot.sh
Source Code Upload
02-04
minify-js.sh
Source Code Upload
02-04
restart.sh
Source Code Upload
02-04
File name
Commit message
Commit date
actions/support
Source Code Upload
02-04
actors
Source Code Upload
02-04
controllers
Source Code Upload
02-04
mailbox
Source Code Upload
02-04
models
Source Code Upload
02-04
playRepository
Source Code Upload
02-04
support
Source Code Upload
02-04
utils
Source Code Upload
02-04
validation
Source Code Upload
02-04
File name
Commit message
Commit date
support
Source Code Upload
02-04
AttachmentTest.java
Source Code Upload
02-04
CodeCommentThreadTest.java
Source Code Upload
02-04
CommentTest.java
Source Code Upload
02-04
CommentThreadTest.java
Source Code Upload
02-04
CommitCommentTest.java
Source Code Upload
02-04
FileDiffTest.java
Source Code Upload
02-04
IssueTest.java
Source Code Upload
02-04
MilestoneTest.java
Source Code Upload
02-04
ModelTest.java
Source Code Upload
02-04
NotificationEventTest.java
Source Code Upload
02-04
NotificationMailTest.java
Source Code Upload
02-04
OrganizationTest.java
Source Code Upload
02-04
OrganizationUserTest.java
Source Code Upload
02-04
PasswordResetTest.java
Source Code Upload
02-04
PostingTest.java
Source Code Upload
02-04
ProjectTest.java
Source Code Upload
02-04
ProjectUserTest.java
Source Code Upload
02-04
PullRequestEventTest.java
Source Code Upload
02-04
PullRequestTest.java
Source Code Upload
02-04
RecentlyVisitedProjectsTest.java
Source Code Upload
02-04
ReviewCommentTest.java
Source Code Upload
02-04
RoleTest.java
Source Code Upload
02-04
SearchResultTests.java
Source Code Upload
02-04
SearchTests.java
Source Code Upload
02-04
TimelineItemTest.java
Source Code Upload
02-04
UserTest.java
Source Code Upload
02-04
WatchTest.java
Source Code Upload
02-04
File name
Commit message
Commit date
FinderTemplateTest.java
Source Code Upload
02-04
ReviewSearchConditionTest.java
Source Code Upload
02-04
Nell 02-04 2600fe6 Source Code Upload UNIX
Raw Open in browser Change history
/** * Yobi, Project Hosting SW * * Copyright 2013 NAVER Corp. * http://yobi.io * * @Author Changsung Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package models.support; import models.*; import org.junit.*; import java.util.List; import play.test.FakeApplication; import play.test.Helpers; import utils.JodaDateUtil; import controllers.ProjectApp; import static org.fest.assertions.Assertions.assertThat; /** * The class to test {@link models.support.ReviewSearchCondition} */ public class ReviewSearchConditionTest extends ModelTest<ReviewSearchCondition> { CommentThread ct1; CommentThread ct2; CommentThread ct3; @Before public void before() { addTestData(); } @After public void after() { clearData(); } /** * Tests searching reviews having the content. */ @Test public void filterForComment() { // given Project project = Project.findByOwnerAndProjectName("yobi", "projectYobi"); ReviewSearchCondition searchCondition = new ReviewSearchCondition(); searchCondition.filter = "111"; searchCondition.state = CommentThread.ThreadState.OPEN.name(); // when List<CommentThread> expressionList = searchCondition.asExpressionList(project).findList(); // then assertThat(expressionList.size()).isEqualTo(1); assertThat(expressionList.get(0).reviewComments.get(0).getContents().contains("111")); } /** * Tests searching reviews written to the commit with commit id. */ @Test public void filterForCommitId() { // given String testCommitId = "300"; Project project = Project.findByOwnerAndProjectName("yobi", "projectYobi"); ReviewSearchCondition searchCondition = new ReviewSearchCondition(); searchCondition.filter = testCommitId; searchCondition.state = CommentThread.ThreadState.OPEN.name(); // when List<CommentThread> expressionList = searchCondition.asExpressionList(project).findList(); // then assertThat(expressionList.size()).isEqualTo(1); CodeCommentThread thread = (CodeCommentThread)expressionList.get(0); assertThat(thread.commitId).contains(testCommitId); } /** * Tests searching reviews written to the file */ @Test public void filterForPath() { // given String testPath = "/app/controllers/IssueApp.java"; Project project = Project.findByOwnerAndProjectName("yobi", "projectYobi"); ReviewSearchCondition searchCondition = new ReviewSearchCondition(); searchCondition.filter = testPath; searchCondition.state = CommentThread.ThreadState.OPEN.name(); // when List<CommentThread> expressionList = searchCondition.asExpressionList(project).findList(); // then assertThat(expressionList.size()).isEqualTo(1); CodeCommentThread thread = (CodeCommentThread)expressionList.get(0); assertThat(thread.codeRange.path).contains(testPath); } /** * Tests searching reviews for contents, commit id and file path. */ @Test public void filterForAll() { // given String testFilter = "controllers"; Project project = Project.findByOwnerAndProjectName("yobi", "projectYobi"); ReviewSearchCondition searchCondition = new ReviewSearchCondition(); searchCondition.filter = testFilter; searchCondition.state = CommentThread.ThreadState.OPEN.name(); // when List<CommentThread> expressionList = searchCondition.asExpressionList(project).findList(); // then assertThat(expressionList.size()).isEqualTo(3); } /** * Tests searching reviews written by the user specified. */ @Test public void searchingAuthor() { // given Project project = Project.findByOwnerAndProjectName("yobi", "projectYobi"); ReviewSearchCondition searchCondition = new ReviewSearchCondition(); searchCondition.authorId = User.findByLoginId("admin").id; searchCondition.state = CommentThread.ThreadState.OPEN.name(); // when List<CommentThread> expressionList = searchCondition.asExpressionList(project).findList(); // then assertThat(expressionList.size()).isEqualTo(2); } /** * Tests searching reviews which the user specified participated in. */ @Test public void searchingParticipant() { // given Project project = Project.findByOwnerAndProjectName("yobi", "projectYobi"); ReviewSearchCondition searchCondition = new ReviewSearchCondition(); searchCondition.participantId = User.findByLoginId("admin").id; searchCondition.state = CommentThread.ThreadState.OPEN.name(); // when List<CommentThread> expressionList = searchCondition.asExpressionList(project).findList(); // then assertThat(expressionList.size()).isEqualTo(2); } /** * Adds test data. */ private void addTestData() { User adminUser = User.findByLoginId("admin"); User lazielUser = User.findByLoginId("laziel"); Project project = Project.findByOwnerAndProjectName("yobi", "projectYobi"); ct1 = addTestThread1(adminUser, lazielUser, project); ct2 = addTestThread2(adminUser, lazielUser, project); ct3 = addTestThread3(adminUser, lazielUser, project); } private void clearData() { ct1.delete(); ct2.delete(); ct3.delete(); } private CommentThread addTestThread1(User admin, User user, Project project) { CodeCommentThread thread = new CodeCommentThread(); thread.createdDate = JodaDateUtil.today(); thread.commitId = "controllers"; thread.state = CommentThread.ThreadState.OPEN; makeThread(admin, "Comment #1 : 111", project, thread); makeComment(thread, user, "Comment #1-1"); makeComment(thread, user, "Comment #1-2"); return thread; } private CommentThread addTestThread2(User admin, User user, Project project) { CodeCommentThread thread = new CodeCommentThread(); thread.createdDate = JodaDateUtil.before(2); thread.commitId = "200"; thread.state = CommentThread.ThreadState.OPEN; makeThread(admin, "Comment #2 : /app/controllers/BoardApp.java", project, thread); makeComment(thread, admin, "Comment #2-1"); makeComment(thread, user, "Comment #2-2"); return thread; } private CommentThread addTestThread3(User admin, User user, Project project) { CodeCommentThread thread = new CodeCommentThread(); thread.createdDate = JodaDateUtil.before(3); thread.commitId = "300"; thread.state = CommentThread.ThreadState.OPEN; thread.codeRange.path = "/app/controllers/IssueApp.java"; makeThread(user, "Comment #3", project, thread); makeComment(thread, user, "Comment #3-1"); makeComment(thread, user, "Comment #3-2"); makeComment(thread, user, "Comment #3-3"); return thread; } /** * Creates a comment and added to {@code thread} * @param thread * @param author * @param contents * @return */ private ReviewComment makeComment(CommentThread thread, User author, String contents) { ReviewComment reviewComment = new ReviewComment(); reviewComment.createdDate = JodaDateUtil.now(); reviewComment.author = new UserIdent(author); reviewComment.thread = thread; reviewComment.setContents(contents); reviewComment.save(); return reviewComment; } /** * Creates a thread. * @param author * @param contents * @param project * @param thread * @return */ private void makeThread(User author, String contents, Project project, CommentThread thread) { thread.project = project; thread.author = new UserIdent(author); thread.save(); ReviewComment reviewComment = new ReviewComment(); reviewComment.createdDate = thread.createdDate; reviewComment.author = thread.author; reviewComment.thread = thread; reviewComment.setContents(contents); reviewComment.save(); } }

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
login with Google Sign in with Google
Reset password | Sign up