Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1064 add default value for static fields to make it easier to write … #1065

Merged

Conversation

asolntsev
Copy link
Contributor

…pure unit tests:

  • Play.configuration
  • Play.id
  • Play.javaPath
  • Play.applicationPath
  • Play.mode
  • Play.templatesPath
  • Play.modulesRoutes
  • Messages.defaults

(PR for issue #1064)

…ier to write pure unit tests:

* Play.configuration
* Play.id
* Play.javaPath
* Play.applicationPath
* Play.mode
* Play.templatesPath
* Play.modulesRoutes
* Messages.defaults
@@ -107,7 +107,7 @@ public static String getMessage(String locale, Object key, Object... args) {
if (value == null && locale != null && locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) {
value = locales.get(locale.substring(0, 2)).getProperty(key.toString());
}
if (value == null && defaults != null) {
if (value == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should keep the test default != null as defaults is public it can be set to null outside the class

@@ -196,7 +196,7 @@ public static Properties all(String locale) {
return defaults;
Properties mergedMessages = new Properties();
mergedMessages.putAll(defaults);
if (locale != null && locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) {
if (locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should keep the test locale != null as locale is public it can be set to null outside the class

@@ -196,7 +196,7 @@ public static Properties all(String locale) {
return defaults;
Properties mergedMessages = new Properties();
mergedMessages.putAll(defaults);
if (locale != null && locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) {
if (locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) {
mergedMessages.putAll(locales.get(locale.substring(0, 2)));
}
mergedMessages.putAll(locales.get(locale));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should as test on locale before using it

@xael-fry xael-fry added this to the 1.4.4 milestone Dec 27, 2016
@xael-fry xael-fry merged commit 62b38cf into playframework:1.4.x Dec 27, 2016
@asolntsev asolntsev deleted the init-play-static-fields-early branch December 27, 2016 06:44
asolntsev added a commit to codeborne/play-web that referenced this pull request Dec 27, 2016
asolntsev added a commit to codeborne/play-liquibase that referenced this pull request Dec 27, 2016
asolntsev added a commit to codeborne/play-rebel that referenced this pull request Dec 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants