use of com.thoughtworks.go.i18n.Localizer in project gocd by gocd.
the class GoConfigServiceTest method shouldUpdateResultAsCouldNotRetrieveConfigDiffWhenGenericExceptionOccurs.
@Test
public void shouldUpdateResultAsCouldNotRetrieveConfigDiffWhenGenericExceptionOccurs() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
Localizer localizer = mock(Localizer.class);
when(configRepo.configChangesFor("md5-5", "md5-4")).thenThrow(new RuntimeException("something"));
goConfigService.configChangesFor("md5-5", "md5-4", result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(SC_INTERNAL_SERVER_ERROR));
result.message(localizer);
verify(localizer).localize("COULD_NOT_RETRIEVE_CONFIG_DIFF", new Object[] {});
}
use of com.thoughtworks.go.i18n.Localizer in project gocd by gocd.
the class AuthorizationControllerTest method setUp.
@Before
public void setUp() throws Exception {
localizer = mock(Localizer.class);
securityAuthConfigService = mock(SecurityAuthConfigService.class);
authorizationController = new AuthorizationController(localizer, securityAuthConfigService);
response = new MockHttpServletResponse();
}
use of com.thoughtworks.go.i18n.Localizer in project gocd by gocd.
the class AuthenticationProcessingFilterTest method setUp.
@Before
public void setUp() throws Exception {
request = new MockHttpServletRequest();
session = new MockHttpSession();
request.setSession(session);
localizer = mock(Localizer.class);
filter = new AuthenticationProcessingFilter(mock(GoConfigService.class), localizer);
}
use of com.thoughtworks.go.i18n.Localizer in project gocd by gocd.
the class HttpLocalizedOperationResultTest method shouldReturn404AndLocalizeWhenNotFound.
@Test
public void shouldReturn404AndLocalizeWhenNotFound() {
Localizable message = mock(Localizable.class);
Localizer localizer = mock(Localizer.class);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
when(message.localize(localizer)).thenReturn("Seriously, whateva");
result.notFound(message, HealthStateType.general(HealthStateScope.GLOBAL));
assertThat(result.httpCode(), is(404));
assertThat(result.message(localizer), is("Seriously, whateva"));
}
use of com.thoughtworks.go.i18n.Localizer in project gocd by gocd.
the class SubsectionLocalizedOperationResultTest method shouldUnderstandErrorStates.
@Test
public void shouldUnderstandErrorStates() throws Exception {
SubsectionLocalizedOperationResult result = new SubsectionLocalizedOperationResult();
result.connectionError(LocalizedMessage.string("foo"));
assertThat("not successful", result.isSuccessful(), is(false));
Localizer localizer = mock(Localizer.class);
when(localizer.localize(any(String.class), anyVararg())).thenReturn("could not connect");
assertThat(result.replacementContent(localizer), is("could not connect"));
}
Aggregations