• 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_YONAsourcetestutilsDiffUtilTest.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
AccessControlTest.java
Source Code Upload
02-04
BasicAuthActionTest.java
Source Code Upload
02-04
ConfigTest.java
Source Code Upload
02-04
DiffUtilTest.java
Source Code Upload
02-04
GravatarUtilTest.java
Source Code Upload
02-04
HttpUtilTest.java
Source Code Upload
02-04
JodaDateUtilTest.java
Source Code Upload
02-04
MailSendTest.java
Source Code Upload
02-04
MarkdownTest.java
Source Code Upload
02-04
MomentUtilTest.java
Source Code Upload
02-04
PullRequestCommitTest.java
Source Code Upload
02-04
ReservedWordsValidatorTest.java
Source Code Upload
02-04
UrlTest.java
Source Code Upload
02-04
YamlUtilTest.java
Source Code Upload
02-04
Nell 02-04 2600fe6 Source Code Upload UNIX
Raw Open in browser Change history
/** * Yona, 21st Century Project Hosting SW * <p> * Copyright Yona & Yobi Authors & NAVER Corp. & NAVER LABS Corp. * https://yona.io **/ package utils; import org.junit.Test; import static org.fest.assertions.Assertions.assertThat; public class DiffUtilTest { String DIFF_DELETE_PREFIX = "<span style='background-color: #fda9a6;padding: 2px 0;'>"; String DIFF_DELETE_POSTFIX = "</span>"; String DIFF_INSERT_PREFIX = "<span style='background-color: #abdd52;padding: 2px 0;'>"; String DIFF_INSERT_POSTFIX = "</span>"; String DIFF_EQUAL_PREFIX = "<span style='color: #bdbdbd;font-size: 16px;font-family: serif;'>...&nbsp<br/>\n" + "......&nbsp<br/>\n" + "......&nbsp<br/>\n" + "...</span>"; String DIFF_NEW_LINE = "\n"; String DIFF_DELETE_PLAIN_PREFIX = "--- "; String DIFF_INSERT_PLAIN_PREFIX = "+++ "; String DIFF_EQUAL_PLAIN_PREFIX = "......\n" + "......\n" + "...\n"; @Test public void getDiffText_oldValueIsNull_returnString() { // GIVEN String oldValue = null; String newValue = "new value"; String expectedResult = DIFF_INSERT_PREFIX + newValue + DIFF_INSERT_POSTFIX; // WHEN String result = DiffUtil.getDiffText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffText_newValueIsNull_returnString() { // GIVEN String oldValue = "oldValue"; String newValue = null; String expectedResult = DIFF_DELETE_PREFIX + oldValue + DIFF_DELETE_POSTFIX; // WHEN String result = DiffUtil.getDiffText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffText_equalValuesMoreThanSize100_returnString() { // GIVEN String oldValue = "12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890"; String newValue = "12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890"; int textLength = oldValue.length(); String expectedResult = oldValue.substring(0, 50) + DIFF_EQUAL_PREFIX + oldValue.substring(textLength - 50); // WHEN String result = DiffUtil.getDiffText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffText_equalValuesLessThanSize100_returnString() { // GIVEN String oldValue = "12345678901234567890"; String newValue = "12345678901234567890"; String expectedResult = oldValue; // WHEN String result = DiffUtil.getDiffText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffText_deleteAndInsertValue_returnString() { // GIVEN String oldValue = "Hi, there?"; String newValue = "Hello, mijeong?"; String expectedResult = oldValue.substring(0, 1) + DIFF_DELETE_PREFIX + oldValue.substring(1, oldValue.length() - 1) + DIFF_DELETE_POSTFIX + DIFF_INSERT_PREFIX + newValue.substring(1, newValue.length() - 1) + DIFF_DELETE_POSTFIX + oldValue.substring(oldValue.length() - 1); // WHEN String result = DiffUtil.getDiffText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffPlainText_oldValueIsNull_returnString() { // GIVEN String oldValue = null; String newValue = "new value"; String expectedResult = DIFF_INSERT_PLAIN_PREFIX + newValue + DIFF_NEW_LINE; // WHEN String result = DiffUtil.getDiffPlainText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffPlainText_newValueIsNull_returnString() { // GIVEN String oldValue = "oldValue"; String newValue = null; String expectedResult = DIFF_DELETE_PLAIN_PREFIX + oldValue + DIFF_NEW_LINE; // WHEN String result = DiffUtil.getDiffPlainText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffPlainText_equalValuesMoreThanSize100_returnString() { // GIVEN String oldValue = "12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890"; String newValue = "12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890"; int textLength = oldValue.length(); String expectedResult = oldValue.substring(0, 50) + DIFF_EQUAL_PLAIN_PREFIX + oldValue.substring(textLength - 50) + DIFF_NEW_LINE; // WHEN String result = DiffUtil.getDiffPlainText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffPlainText_equalValuesLessThanSize100_returnString() { // GIVEN String oldValue = "12345678901234567890"; String newValue = "12345678901234567890"; String expectedResult = oldValue + DIFF_NEW_LINE; // WHEN String result = DiffUtil.getDiffPlainText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } @Test public void getDiffPlainText_deleteAndInsertValue_returnString() { // GIVEN String oldValue = "Hi, there?"; String newValue = "Hello, mijeong?"; String expectedResult = oldValue.substring(0, 1) + DIFF_NEW_LINE + DIFF_DELETE_PLAIN_PREFIX + oldValue.substring(1, oldValue.length() - 1) + DIFF_NEW_LINE + DIFF_INSERT_PLAIN_PREFIX + newValue.substring(1, newValue.length() - 1) + DIFF_NEW_LINE + oldValue.substring(oldValue.length() - 1) + DIFF_NEW_LINE; // WHEN String result = DiffUtil.getDiffPlainText(oldValue, newValue); // THEN assertThat(result).isEqualTo(expectedResult); } }

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

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