• 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_YONAsourcetestmailboxCreationViaEmailTest.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
CreationViaEmailTest.java
Source Code Upload
02-04
EmailAddressWithDetailTest.java
Source Code Upload
02-04
IMAPMessageUtilTest.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 2014 NAVER Corp. * http://yobi.io * * @Author Yi EungJun * * 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 mailbox; import com.sun.mail.imap.IMAPMessage; import models.*; import models.enumeration.State; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import play.test.FakeApplication; import play.test.Helpers; import utils.JodaDateUtil; import javax.mail.Message; import javax.mail.internet.InternetAddress; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class CreationViaEmailTest { private static FakeApplication app; private User member; private Project project; @BeforeClass public static void startApp() { app = support.Helpers.makeTestApplication(); Helpers.start(app); } @AfterClass public static void stopApp() { Helpers.stop(app); } @Before public void before() { project = Project.findByOwnerAndProjectName("yobi", "projectYobi"); member = User.findByLoginId("laziel"); } public static Content createTestContent(String body, String type) { Content content = new Content(); content.body = body; content.type = type; return content; } @Test public void saveIssue() throws Exception { // Given String title = "title"; Content content = createTestContent("body", "text/plain"); InternetAddress[] recipients = new InternetAddress[]{ new InternetAddress("foo@mail.com") }; // When Issue issue = CreationViaEmail.saveIssue(title, project, member, content, "<message-id@domain>", recipients); issue.refresh(); // Then assertThat(issue.authorId).describedAs("author").isEqualTo(member.id); assertThat(issue.title).describedAs("title").isEqualTo(title); assertThat(issue.body).describedAs("body").isEqualTo(content.body); assertThat(issue.project).describedAs("project").isEqualTo(project); } @Test public void saveComment() throws Exception { // Given IMAPMessage message = mock(IMAPMessage.class); when(message.getAllRecipients()).thenReturn(new InternetAddress[]{ new InternetAddress("foo@mail.com") }); when(message.getFrom()).thenReturn(new InternetAddress[]{ new InternetAddress(member.email) }); when(message.getContentType()).thenReturn("text/plain"); when(message.isMimeType("text/*")).thenReturn(true); when(message.getContent()).thenReturn("body"); when(message.getMessageID()).thenReturn("<message-id-2@domain>"); Issue issue = new Issue(); issue.setProject(project); issue.setTitle("hello"); issue.setBody("world"); issue.setAuthor(member); issue.state = State.OPEN; issue.save(); // When Comment comment = CreationViaEmail.saveComment(message, issue.asResource()); comment.refresh(); // Then assertThat(comment.authorId) .describedAs("authorId") .isEqualTo(member.id); assertThat(comment.contents) .describedAs("contents") .isEqualTo((String) message.getContent()); assertThat(comment.getParent().id) .describedAs("parent") .isEqualTo(issue.id); } @Test public void saveReviewComment() throws Exception { // Given Content content = createTestContent("body", "text/plain"); InternetAddress[] recipients = new InternetAddress[]{ new InternetAddress("foo@mail.com") }; NonRangedCodeCommentThread thread = new NonRangedCodeCommentThread(); thread.project = project; thread.commitId = "123321"; thread.state = CommentThread.ThreadState.OPEN; thread.createdDate = JodaDateUtil.before(1); thread.save(); // When ReviewComment comment = CreationViaEmail.saveReviewComment( thread.asResource(), member, content, "<message-id-3@domain>", recipients); // Then assertThat(comment.author.id) .describedAs("author.id") .isEqualTo(member.id); assertThat(comment.getContents()) .describedAs("contents") .isEqualTo(content.body); assertThat(comment.thread.id) .describedAs("thread") .isEqualTo(thread.id); } }

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

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