Skip to content

Commit

Permalink
[Tests] Use lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
skerdudou committed Jan 22, 2024
1 parent 3d0e85c commit 4aee1df
Showing 1 changed file with 8 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,57 +119,33 @@ public void testDynamicMessageKey() {
/*
* On teste que l'on accède au dictionnaire par une clé sous forme de chaine de caractères.
*/
final LocaleMessageKey key = new LocaleMessageKey() {
private static final long serialVersionUID = 1L;

@Override
public String name() {
return "HELLO";
}
};
final LocaleMessageKey key = () -> "HELLO";

assertEquals("bonjour", localeManager.getMessage(key, Locale.FRANCE));
assertEquals("guten tag", localeManager.getMessage(key, Locale.GERMANY));
assertEquals("hello", localeManager.getMessage(key, Locale.ENGLISH));
}

@Test
public void testDefaultDynamicMessageKey() {
final LocaleMessageKey key = new LocaleMessageKey() {
private static final long serialVersionUID = 1L;

@Override
public String name() {
return "UNKNOWN KEY";
}
};
final LocaleMessageKey key = () -> "UNKNOWN KEY";

final LocaleMessageText helloTxt = LocaleMessageText.ofDefaultMsg("bonjour par défaut", key);
assertEquals("bonjour par défaut", helloTxt.getDisplay());
}

@Test
public void testUnknownDynamicMessageKey() {
final LocaleMessageKey key = new LocaleMessageKey() {
private static final long serialVersionUID = 1L;

@Override
public String name() {
return "UNKNOWN KEY";
}
};
final LocaleMessageKey key = () -> "UNKNOWN KEY";

final LocaleMessageText helloTxt = LocaleMessageText.of(key);
assertEquals("<<fr:UNKNOWN KEY>>", helloTxt.getDisplay());
}

@Test
public void testMessageTextParams() {
final LocaleMessageKey key = new LocaleMessageKey() {
private static final long serialVersionUID = 1L;

@Override
public String name() {
return "UNKNOWN KEY";
}
};
final LocaleMessageKey key = () -> "UNKNOWN KEY";

final Serializable param = null;
LocaleMessageText helloTxt = LocaleMessageText.of(key);
assertEquals("<<fr:UNKNOWN KEY>>", helloTxt.getDisplay());
Expand Down

0 comments on commit 4aee1df

Please sign in to comment.