Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ss-Android into feature/Plans-M1-Show-Plans-List

Conflicts:
	WordPress/src/main/java/org/wordpress/android/WordPressDB.java
  • Loading branch information
nbradbury committed Feb 16, 2016
2 parents da10360 + fc52906 commit 3194ade
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion WordPressUtils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
buildToolsVersion "23.0.2"

defaultConfig {
versionName "1.8.0"
versionName "1.9.0"
minSdkVersion 14
targetSdkVersion 23
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.wordpress.android.util;

import android.test.InstrumentationTestCase;

public class ShortcodeUtilsTest extends InstrumentationTestCase {
public void testGetVideoPressShortcodeFromId() {
assertEquals("[wpvideo abcd1234]", ShortcodeUtils.getVideoPressShortcodeFromId("abcd1234"));
}

public void testGetVideoPressShortcodeFromNullId() {
assertEquals("", ShortcodeUtils.getVideoPressShortcodeFromId(null));
}

public void testGetVideoPressIdFromCorrectShortcode() {
assertEquals("abcd1234", ShortcodeUtils.getVideoPressIdFromShortCode("[wpvideo abcd1234]"));
}

public void testGetVideoPressIdFromInvalidShortcode() {
assertEquals("", ShortcodeUtils.getVideoPressIdFromShortCode("[other abcd1234]"));
}

public void testGetVideoPressIdFromNullShortcode() {
assertEquals("", ShortcodeUtils.getVideoPressIdFromShortCode(null));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.wordpress.android.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ShortcodeUtils {
public static String getVideoPressShortcodeFromId(String videoPressId) {
if (videoPressId == null || videoPressId.isEmpty()) {
return "";
}

return "[wpvideo " + videoPressId + "]";
}

public static String getVideoPressIdFromShortCode(String shortcode) {
String videoPressId = "";

if (shortcode != null) {
String videoPressShortcodeRegex = "^\\[wpvideo (.*)]$";

Pattern pattern = Pattern.compile(videoPressShortcodeRegex);
Matcher matcher = pattern.matcher(shortcode);

if (matcher.find()) {
videoPressId = matcher.group(1);
}
}

return videoPressId;
}
}

0 comments on commit 3194ade

Please sign in to comment.