Added tests.

This commit is contained in:
Erik C. Thauvin 2017-05-31 00:21:34 -07:00
parent f9f219abe5
commit cf2d964b6e
6 changed files with 226 additions and 7 deletions

View file

@ -143,6 +143,16 @@ final public class Utils {
return (Commands.LINK_CMD + (entryIndex + 1) + "T: " + entry.getPinboardTags().replaceAll(",", ", "));
}
/**
* Capitalize a string.
*
* @param s The string.
* @return The capitalized string.
*/
public static String capitalize(final String s) {
return s.substring(0, 1).toUpperCase() + s.substring(1);
}
/**
* Ensures that the given location (File/URL) has a trailing slash (<code>/</code>) to indicate a directory.
*
@ -169,7 +179,7 @@ final public class Utils {
/**
* Returns a property as an int.
*
* @param property The port property value.
* @param property The property value.
* @param def The default property value.
* @return The port or default value if invalid.
*/
@ -300,7 +310,7 @@ final public class Utils {
* Returns the specified date formatted as <code>yyyy-MM-dd HH:mm</code>
*
* @param date The date.
* @return The fromatted date.
* @return The formatted date.
*/
public static String utcDateTime(final LocalDateTime date) {
return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));

View file

@ -63,10 +63,6 @@ public class Weather2 extends AbstractModule {
properties.put(OWM_API_KEY_PROP, "");
}
private String capitalize(final String s) {
return s.substring(0, 1).toUpperCase() + s.substring(1);
}
/**
* {@inheritDoc}
*/
@ -147,7 +143,7 @@ public class Weather2 extends AbstractModule {
if (i != 0) {
condition.append(", ").append(w.getWeatherDescription());
} else {
condition.append(capitalize(w.getWeatherDescription()));
condition.append(Utils.capitalize(w.getWeatherDescription()));
}
}
bot.send(sender, condition.toString(), isPrivate);