Search in sources :

Example 1 with ThrowingSupplier

use of com.synopsys.integration.function.ThrowingSupplier in project hub-alert by blackducksoftware.

the class ConfigurationCrudHelperTest method testUpdateException.

@Test
public void testUpdateException() {
    AuthenticationTestUtils authenticationTestUtils = new AuthenticationTestUtils();
    DescriptorKey descriptorKey = new ChannelKey("channel_key", "channel-display-name");
    PermissionKey permissionKey = new PermissionKey(ConfigContextEnum.GLOBAL.name(), descriptorKey.getUniversalKey());
    Map<PermissionKey, Integer> permissions = Map.of(permissionKey, AuthenticationTestUtils.FULL_PERMISSIONS);
    AuthorizationManager authorizationManager = authenticationTestUtils.createAuthorizationManagerWithCurrentUserSet("admin", "admin", () -> new PermissionMatrixModel(permissions));
    ThrowingSupplier createdModelSupplier = () -> {
        throw new AlertException("error getting test message");
    };
    ConfigurationCrudHelper configurationHelper = new ConfigurationCrudHelper(authorizationManager, ConfigContextEnum.GLOBAL, descriptorKey);
    ActionResponse response = configurationHelper.update(() -> ValidationResponseModel.success(), () -> true, createdModelSupplier);
    assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getHttpStatus());
}
Also used : PermissionMatrixModel(com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel) PermissionKey(com.synopsys.integration.alert.common.persistence.model.PermissionKey) ChannelKey(com.synopsys.integration.alert.descriptor.api.model.ChannelKey) AuthenticationTestUtils(com.synopsys.integration.alert.test.common.AuthenticationTestUtils) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) ThrowingSupplier(com.synopsys.integration.function.ThrowingSupplier) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse) Test(org.junit.jupiter.api.Test)

Aggregations

AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)1 PermissionKey (com.synopsys.integration.alert.common.persistence.model.PermissionKey)1 PermissionMatrixModel (com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel)1 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)1 ChannelKey (com.synopsys.integration.alert.descriptor.api.model.ChannelKey)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1 AuthenticationTestUtils (com.synopsys.integration.alert.test.common.AuthenticationTestUtils)1 ThrowingSupplier (com.synopsys.integration.function.ThrowingSupplier)1 Test (org.junit.jupiter.api.Test)1