Search in sources :

Example 11 with Localizer

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[] {});
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Localizer(com.thoughtworks.go.i18n.Localizer) Test(org.junit.Test)

Example 12 with Localizer

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();
}
Also used : SecurityAuthConfigService(com.thoughtworks.go.server.service.SecurityAuthConfigService) Localizer(com.thoughtworks.go.i18n.Localizer) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Example 13 with Localizer

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);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpSession(org.springframework.mock.web.MockHttpSession) Localizer(com.thoughtworks.go.i18n.Localizer) Before(org.junit.Before)

Example 14 with 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"));
}
Also used : Localizer(com.thoughtworks.go.i18n.Localizer) Localizable(com.thoughtworks.go.i18n.Localizable) Test(org.junit.Test)

Example 15 with Localizer

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"));
}
Also used : Localizer(com.thoughtworks.go.i18n.Localizer) Test(org.junit.Test)

Aggregations

Localizer (com.thoughtworks.go.i18n.Localizer)21 Test (org.junit.Test)14 Username (com.thoughtworks.go.server.domain.Username)5 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)5 Before (org.junit.Before)5 GoConfigValidity (com.thoughtworks.go.config.validation.GoConfigValidity)3 PipelineGroupNotFoundException (com.thoughtworks.go.config.exceptions.PipelineGroupNotFoundException)2 Localizable (com.thoughtworks.go.i18n.Localizable)2 SchedulingPerformanceLogger (com.thoughtworks.go.server.perf.SchedulingPerformanceLogger)2 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)2 TestTransactionTemplate (com.thoughtworks.go.server.transaction.TestTransactionTemplate)2 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)2 TimeProvider (com.thoughtworks.go.util.TimeProvider)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 TaskExtension (com.thoughtworks.go.plugin.access.pluggabletask.TaskExtension)1 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)1 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)1 TaskConfigProperty (com.thoughtworks.go.plugin.api.task.TaskConfigProperty)1 SecurityAuthConfigService (com.thoughtworks.go.server.service.SecurityAuthConfigService)1