Search in sources :

Example 16 with AlertFieldException

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

the class CommonConfigHandlerTest method putWithInvalidConfigTest.

@Test
public void putWithInvalidConfigTest() throws AlertFieldException {
    final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
    final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
    Mockito.when(configActions.doesConfigExist(Mockito.anyString())).thenReturn(true);
    Mockito.when(configActions.validateConfig(Mockito.any())).thenThrow(new AlertFieldException(Collections.emptyMap()));
    Mockito.when(configActions.getObjectTransformer()).thenReturn(objectTransformer);
    final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
    final ResponseEntity<String> response = handler.putConfig(restModel);
    assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) AlertFieldException(com.blackducksoftware.integration.hub.alert.exception.AlertFieldException) Test(org.junit.Test)

Example 17 with AlertFieldException

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

the class CommonConfigHandlerTest method validateConfigWithInvalidConfigTest.

@Test
public void validateConfigWithInvalidConfigTest() throws AlertFieldException {
    final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
    final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
    Mockito.when(configActions.validateConfig(Mockito.any())).thenThrow(new AlertFieldException(Collections.emptyMap()));
    Mockito.when(configActions.getObjectTransformer()).thenReturn(objectTransformer);
    final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
    final ResponseEntity<String> response = handler.validateConfig(restModel);
    assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) AlertFieldException(com.blackducksoftware.integration.hub.alert.exception.AlertFieldException) Test(org.junit.Test)

Aggregations

AlertFieldException (com.blackducksoftware.integration.hub.alert.exception.AlertFieldException)17 Test (org.junit.Test)8 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)5 CommonDistributionRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper)4 CommonDistributionConfigActions (com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions)4 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)4 ValidationResults (com.blackducksoftware.integration.validator.ValidationResults)4 HashMap (java.util.HashMap)4 GlobalActionsTest (com.blackducksoftware.integration.hub.alert.web.actions.global.GlobalActionsTest)3 ResponseBodyBuilder (com.blackducksoftware.integration.hub.alert.web.model.ResponseBodyBuilder)3 AbstractValidator (com.blackducksoftware.integration.validator.AbstractValidator)3 FieldEnum (com.blackducksoftware.integration.validator.FieldEnum)3 ValidationResult (com.blackducksoftware.integration.validator.ValidationResult)3 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)2 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)2 HubServerConfigBuilder (com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder)2 IntLogger (com.blackducksoftware.integration.log.IntLogger)2 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1