Search in sources :

Example 6 with IntegrationRestException

use of com.blackducksoftware.integration.hub.rest.exception.IntegrationRestException in project hub-alert by blackducksoftware.

the class LoginHandlerTest method authenticateUserWithIntegrationRestExceptionTest.

@Test
public void authenticateUserWithIntegrationRestExceptionTest() throws IntegrationException {
    final LoginActions loginActions = Mockito.mock(LoginActions.class);
    final LoginHandler loginHandler = new LoginHandler(objectTransformer, loginActions, csrfTokenRepository);
    final HttpStatus responseCode = HttpStatus.BAD_GATEWAY;
    Mockito.when(loginActions.authenticateUser(Mockito.any(), Mockito.any())).thenThrow(new IntegrationRestException(responseCode.value(), "", ""));
    final ResponseEntity<String> response = loginHandler.authenticateUser(null, null, null);
    assertEquals(responseCode, response.getStatusCode());
}
Also used : IntegrationRestException(com.blackducksoftware.integration.hub.rest.exception.IntegrationRestException) HttpStatus(org.springframework.http.HttpStatus) LoginActions(com.blackducksoftware.integration.hub.alert.web.actions.LoginActions) Test(org.junit.Test)

Aggregations

IntegrationRestException (com.blackducksoftware.integration.hub.rest.exception.IntegrationRestException)6 Test (org.junit.Test)4 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)2 Gson (com.google.gson.Gson)2 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)1 CommonDistributionRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper)1 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)1 AlertFieldException (com.blackducksoftware.integration.hub.alert.exception.AlertFieldException)1 LoginActions (com.blackducksoftware.integration.hub.alert.web.actions.LoginActions)1 CommonDistributionConfigActions (com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions)1 ResponseBodyBuilder (com.blackducksoftware.integration.hub.alert.web.model.ResponseBodyBuilder)1 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)1 IntLogger (com.blackducksoftware.integration.log.IntLogger)1 PrintStreamIntLogger (com.blackducksoftware.integration.log.PrintStreamIntLogger)1 HttpStatus (org.springframework.http.HttpStatus)1 CsrfToken (org.springframework.security.web.csrf.CsrfToken)1