use of pl.edu.icm.unity.MessageSource in project unity by unity-idm.
the class StrengthCheckerTest method shouldReturnLowScoreForBadPassword.
@Test
public void shouldReturnLowScoreForBadPassword() throws IOException {
MessageSource msg = mock(MessageSource.class);
when(msg.getMessage(eq("feedback.repeat.warning.likeABCABCABC"), any(), any())).thenReturn("ok1");
when(msg.getMessage(eq("feedback.extra.suggestions.addAnotherWord"), any(), any())).thenReturn("o2k");
when(msg.getMessage(eq("feedback.repeat.suggestions.avoidRepeatedWords"), any(), any())).thenReturn("ok3");
StrengthInfo result = StrengthChecker.measure("soso", 10, Locale.ENGLISH, msg);
assertThat("" + result.scoreNormalized, result.scoreNormalized < 0.15, is(true));
}
use of pl.edu.icm.unity.MessageSource in project unity by unity-idm.
the class RegistrationFormTest method shouldValidateLayoutWhenLocalSignupEmbeddedAsButton.
@Test
public void shouldValidateLayoutWhenLocalSignupEmbeddedAsButton() {
RegistrationForm complete = getRegistrationForm();
MessageSource msg = Mockito.mock(MessageSource.class);
RegistrationFormLayouts layouts = new RegistrationFormLayouts();
layouts.setLocalSignupEmbeddedAsButton(true);
complete.setFormLayouts(layouts);
layouts.setPrimaryLayout(complete.getEffectivePrimaryFormLayout(msg));
layouts.setSecondaryLayout(complete.getEffectiveSecondaryFormLayout(msg));
layouts.validate(complete);
Throwable exception = catchThrowable(() -> layouts.validate(complete));
assertThat(exception).isNull();
}
use of pl.edu.icm.unity.MessageSource in project unity by unity-idm.
the class SafePanel method setCaptionFromBundle.
public void setCaptionFromBundle(MessageSource msg, String key, Object... args) {
Escaper htmlEscaper = HtmlEscapers.htmlEscaper();
Object[] escapedArgs = Arrays.stream(args).map(arg -> htmlEscaper.escape(arg.toString())).toArray();
String message = msg.getMessage(key, escapedArgs);
setCaptionAsHtml(true);
super.setCaption(message);
}
use of pl.edu.icm.unity.MessageSource in project unity by unity-idm.
the class I18nTextFieldTest method preservesValue.
@Test
public void preservesValue() {
MessageSource msg = mock(MessageSource.class);
when(msg.getDefaultLocaleCode()).thenReturn("en");
Map<String, Locale> locales = new HashMap<>();
locales.put("english", new Locale("en"));
locales.put("polski", new Locale("pl"));
when(msg.getEnabledLocales()).thenReturn(locales);
I18nTextField tf = new I18nTextField(msg);
I18nString original = new I18nString("a");
original.addValue("en", "Value 1");
original.addValue("pl", "Wartość 1");
tf.setValue(original);
I18nString ret = tf.getValue();
Assert.assertEquals(original, ret);
}
use of pl.edu.icm.unity.MessageSource in project unity by unity-idm.
the class StrengthCheckerTest method shouldReturnMaxScoreForGoodPassword.
@Test
public void shouldReturnMaxScoreForGoodPassword() throws IOException {
MessageSource msg = mock(MessageSource.class);
StrengthInfo result = StrengthChecker.measure("horsedonteathorseradishondisk", 10, Locale.ENGLISH, msg);
assertThat("" + result.scoreNormalized, result.scoreNormalized, is(1.0));
}
Aggregations