• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ProjectApiErrors类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors的典型用法代码示例。如果您正苦于以下问题:Java ProjectApiErrors类的具体用法?Java ProjectApiErrors怎么用?Java ProjectApiErrors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProjectApiErrors类属于com.nike.backstopper.apierror.projectspecificinfo包,在下文中一共展示了ProjectApiErrors类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ApiExceptionHandlerBase

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * Creates a new instance with the given arguments.
 *
 * @param projectApiErrors The {@link ProjectApiErrors} used for this project - cannot be null.
 * @param apiExceptionHandlerListenerList
 *          The list of {@link ApiExceptionHandlerListener}s that will be used for this project to analyze
 *          exceptions and see if they should be handled (and how they should be handled if so). These will be
 *          executed in list order. This cannot be null (pass in an empty list if you really don't have any
 *          listeners for your project, however this should never be the case in practice - you should always
 *          include {@link com.nike.backstopper.handler.listener.impl.GenericApiExceptionHandlerListener}
 *          at the very least).
 * @param utils The {@link ApiExceptionHandlerUtils} that should be used by this instance. You can pass in
 *              {@link ApiExceptionHandlerUtils#DEFAULT_IMPL} if you don't need custom logic. Cannot be null.
 */
public ApiExceptionHandlerBase(ProjectApiErrors projectApiErrors,
                               List<ApiExceptionHandlerListener> apiExceptionHandlerListenerList,
                               ApiExceptionHandlerUtils utils) {
    if (projectApiErrors == null)
        throw new IllegalArgumentException("projectApiErrors cannot be null.");

    if (apiExceptionHandlerListenerList == null)
        throw new IllegalArgumentException("apiExceptionHandlerListenerList cannot be null.");

    if (utils == null)
        throw new IllegalArgumentException("apiExceptionHandlerUtils cannot be null.");

    this.projectApiErrors = projectApiErrors;
    this.apiExceptionHandlerListenerList = apiExceptionHandlerListenerList;
    this.utils = utils;
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:31,代码来源:ApiExceptionHandlerBase.java


示例2: verifyErrorResponse

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * Verifies that the given MvcResult's {@link org.springframework.test.web.servlet.MvcResult#getResponse()} has the
 * expected HTTP status code, that its contents can be converted to the appropriate {@link DefaultErrorContractDTO} with the
 * expected errors (as per the default error handling contract), and that the MvcResult's {@link
 * org.springframework.test.web.servlet.MvcResult#getResolvedException()} matches the given expectedExceptionType.
 */
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
protected void verifyErrorResponse(MvcResult result, ProjectApiErrors projectApiErrors,
                                   List<ApiError> expectedErrors, Class<? extends Exception> expectedExceptionType)
    throws IOException {
    Integer expectedStatusCode = projectApiErrors.determineHighestPriorityHttpStatusCode(expectedErrors);
    expectedErrors = projectApiErrors.getSublistContainingOnlyHttpStatusCode(expectedErrors, expectedStatusCode);
    MockHttpServletResponse response = result.getResponse();
    assertThat(response.getStatus(), is(expectedStatusCode));
    DefaultErrorContractDTO details =
        objectMapper.readValue(response.getContentAsString(), DefaultErrorContractDTO.class);
    assertNotNull(details);
    assertNotNull(details.error_id);
    assertNotNull(details.errors);
    assertThat(details.errors.size(), is(expectedErrors.size()));
    List<Pair<String, String>> expectedErrorsAsPairs = convertToCodeAndMessagePairs(expectedErrors);
    for (DefaultErrorDTO errorView : details.errors) {
        assertTrue(expectedErrorsAsPairs.contains(Pair.of(errorView.code, errorView.message)));
    }
    assertNotNull(result.getResolvedException());
    Assertions.assertThat(result.getResolvedException()).isInstanceOf(expectedExceptionType);
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:28,代码来源:BaseSpringEnabledValidationTestCase.java


示例3: riposteErrorHandler

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * @return The error handler that should be used for this application for handling known errors. For things that
 * fall through the cracks they will be handled by {@link #riposteUnhandledErrorHandler()}.
 *
 * <p>NOTE: The default implementation returned if you don't override this method is a very basic Backstopper impl -
 * it will not know about your application's {@link ProjectApiErrors} and will instead create a dummy {@link
 * ProjectApiErrors} that only supports the {@link com.nike.backstopper.apierror.sample.SampleCoreApiError} values.
 * This method should be overridden for most real applications to return a real implementation tailored for your
 * app. In practice this usually means copy/pasting this method and simply supplying the correct {@link
 * ProjectApiErrors} for the app. The rest is usually fine for defaults.
 */
default RiposteErrorHandler riposteErrorHandler() {
    ProjectApiErrors projectApiErrors = new SampleProjectApiErrorsBase() {
        @Override
        protected List<ApiError> getProjectSpecificApiErrors() {
            return null;
        }

        @Override
        protected ProjectSpecificErrorCodeRange getProjectSpecificErrorCodeRange() {
            return null;
        }
    };
    return BackstopperRiposteConfigHelper
        .defaultErrorHandler(projectApiErrors, ApiExceptionHandlerUtils.DEFAULT_IMPL);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:27,代码来源:ServerConfig.java


示例4: riposteUnhandledErrorHandler

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * @return The error handler that should be used for this application for handling unknown/unexpected/unhandled
 * errors. Known/handled errors will be processed by {@link #riposteErrorHandler()}.
 *
 * <p>NOTE: The default implementation returned if you don't override this method is a very basic Backstopper impl -
 * it will not know about your application's {@link ProjectApiErrors} and will instead create a dummy {@link
 * ProjectApiErrors} that only supports the {@link com.nike.backstopper.apierror.sample.SampleCoreApiError} values.
 * This method should be overridden for most real applications to return a real implementation tailored for your
 * app. In practice this usually means copy/pasting this method and simply supplying the correct {@link
 * ProjectApiErrors} for the app. The rest is usually fine for defaults.
 */
default RiposteUnhandledErrorHandler riposteUnhandledErrorHandler() {
    ProjectApiErrors projectApiErrors = new SampleProjectApiErrorsBase() {
        @Override
        protected List<ApiError> getProjectSpecificApiErrors() {
            return null;
        }

        @Override
        protected ProjectSpecificErrorCodeRange getProjectSpecificErrorCodeRange() {
            return null;
        }
    };
    return BackstopperRiposteConfigHelper
        .defaultUnhandledErrorHandler(projectApiErrors, ApiExceptionHandlerUtils.DEFAULT_IMPL);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:27,代码来源:ServerConfig.java


示例5: constructorWorksIfPassedValidValues

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test
public void constructorWorksIfPassedValidValues() {
    // when
    RiposteApiExceptionHandler
        myAdapter = new RiposteApiExceptionHandler(projectApiErrors, validListenerList, utils);

    // then
    List<ApiExceptionHandlerListener> actualListeners =
        (List<ApiExceptionHandlerListener>) Whitebox.getInternalState(myAdapter, "apiExceptionHandlerListenerList");
    ProjectApiErrors actualProjectApiErrors =
        (ProjectApiErrors) Whitebox.getInternalState(myAdapter, "projectApiErrors");
    ApiExceptionHandlerUtils actualUtils = (ApiExceptionHandlerUtils) Whitebox.getInternalState(myAdapter, "utils");
    assertThat(actualListeners, is(validListenerList));
    assertThat(actualProjectApiErrors, is(projectApiErrors));
    assertThat(actualUtils, is(utils));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:17,代码来源:RiposteApiExceptionHandlerTest.java


示例6: UnhandledExceptionHandlerBase

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * Creates a new instance with the given arguments.
 *
 * @param projectApiErrors The {@link ProjectApiErrors} used for this project - cannot be null.
 * @param utils The {@link ApiExceptionHandlerUtils} that should be used by this instance. You can pass in
 *              {@link ApiExceptionHandlerUtils#DEFAULT_IMPL} if you don't need custom logic.
 */
public UnhandledExceptionHandlerBase(ProjectApiErrors projectApiErrors, ApiExceptionHandlerUtils utils) {
    if (projectApiErrors == null)
        throw new IllegalArgumentException("projectApiErrors cannot be null.");

    if (utils == null)
        throw new IllegalArgumentException("apiExceptionHandlerUtils cannot be null.");

    this.projectApiErrors = projectApiErrors;
    this.utils = utils;
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:18,代码来源:UnhandledExceptionHandlerBase.java


示例7: ClientDataValidationErrorHandlerListener

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * @param projectApiErrors The {@link ProjectApiErrors} that should be used by this instance when finding
 *                          {@link ApiError}s. Cannot be null.
 * @param utils The {@link ApiExceptionHandlerUtils} that should be used by this instance. You can pass in
 *              {@link ApiExceptionHandlerUtils#DEFAULT_IMPL} if you don't need custom logic.
 */
@Inject
public ClientDataValidationErrorHandlerListener(ProjectApiErrors projectApiErrors,
                                                ApiExceptionHandlerUtils utils) {
    if (projectApiErrors == null)
        throw new IllegalArgumentException("ProjectApiErrors cannot be null");

    if (utils == null)
        throw new IllegalArgumentException("apiExceptionHandlerUtils cannot be null.");

    this.projectApiErrors = projectApiErrors;
    this.utils = utils;
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:19,代码来源:ClientDataValidationErrorHandlerListener.java


示例8: DownstreamNetworkExceptionHandlerListener

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * @param projectApiErrors The {@link ProjectApiErrors} that should be used by this instance when finding
 *                          {@link ApiError}s. Cannot be null.
 */
@Inject
public DownstreamNetworkExceptionHandlerListener(ProjectApiErrors projectApiErrors) {
    if (projectApiErrors == null)
        throw new IllegalArgumentException("ProjectApiErrors cannot be null");

    this.projectApiErrors = projectApiErrors;
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:12,代码来源:DownstreamNetworkExceptionHandlerListener.java


示例9: ServersideValidationErrorHandlerListener

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * @param projectApiErrors The {@link ProjectApiErrors} that should be used by this instance when finding
 *                          {@link ApiError}s. Cannot be null.
 * @param utils The {@link ApiExceptionHandlerUtils} that should be used by this instance. You can pass in
 *              {@link ApiExceptionHandlerUtils#DEFAULT_IMPL} if you don't need custom logic.
 */
@Inject
public ServersideValidationErrorHandlerListener(ProjectApiErrors projectApiErrors,
                                                ApiExceptionHandlerUtils utils) {
    if (projectApiErrors == null)
        throw new IllegalArgumentException("ProjectApiErrors cannot be null");

    if (utils == null)
        throw new IllegalArgumentException("apiExceptionHandlerUtils cannot be null.");

    this.projectApiErrors = projectApiErrors;
    this.utils = utils;
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:19,代码来源:ServersideValidationErrorHandlerListener.java


示例10: constructor_sets_projectApiErrors_and_utils_to_passed_in_args

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test
public void constructor_sets_projectApiErrors_and_utils_to_passed_in_args() {
    // given
    ProjectApiErrors projectErrorsMock = mock(ProjectApiErrors.class);
    ApiExceptionHandlerUtils utilsMock = mock(ApiExceptionHandlerUtils.class);

    // when
    ClientDataValidationErrorHandlerListener impl = new ClientDataValidationErrorHandlerListener(projectErrorsMock, utilsMock);

    // then
    Assertions.assertThat(impl.projectApiErrors).isSameAs(projectErrorsMock);
    Assertions.assertThat(impl.utils).isSameAs(utilsMock);
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:14,代码来源:ClientDataValidationErrorHandlerListenerTest.java


示例11: constructor_throws_IllegalArgumentException_if_passed_null_utils

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test
public void constructor_throws_IllegalArgumentException_if_passed_null_utils() {
    // when
    Throwable ex = Assertions.catchThrowable(new ThrowableAssert.ThrowingCallable() {
        @Override
        public void call() throws Throwable {
            new ClientDataValidationErrorHandlerListener(mock(ProjectApiErrors.class), null);
        }
    });

    // then
    Assertions.assertThat(ex).isInstanceOf(IllegalArgumentException.class);
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:14,代码来源:ClientDataValidationErrorHandlerListenerTest.java


示例12: constructor_sets_projectApiErrors_and_utils_to_passed_in_args

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test
public void constructor_sets_projectApiErrors_and_utils_to_passed_in_args() {
    // given
    ProjectApiErrors projectErrorsMock = mock(ProjectApiErrors.class);
    ApiExceptionHandlerUtils utilsMock = mock(ApiExceptionHandlerUtils.class);

    // when
    ServersideValidationErrorHandlerListener impl = new ServersideValidationErrorHandlerListener(projectErrorsMock, utilsMock);

    // then
    Assertions.assertThat(impl.projectApiErrors).isSameAs(projectErrorsMock);
    Assertions.assertThat(impl.utils).isSameAs(utilsMock);
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:14,代码来源:ServersideValidationErrorHandlerListenerTest.java


示例13: constructor_throws_IllegalArgumentException_if_passed_null_utils

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test
public void constructor_throws_IllegalArgumentException_if_passed_null_utils() {
    // when
    Throwable ex = Assertions.catchThrowable(new ThrowableAssert.ThrowingCallable() {
        @Override
        public void call() throws Throwable {
            new ServersideValidationErrorHandlerListener(mock(ProjectApiErrors.class), null);
        }
    });

    // then
    Assertions.assertThat(ex).isInstanceOf(IllegalArgumentException.class);
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:14,代码来源:ServersideValidationErrorHandlerListenerTest.java


示例14: constructor_sets_projectApiErrors_to_passed_in_arg

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test
public void constructor_sets_projectApiErrors_to_passed_in_arg() {
    // given
    ProjectApiErrors projectErrorsMock = mock(ProjectApiErrors.class);

    // when
    DownstreamNetworkExceptionHandlerListener impl = new DownstreamNetworkExceptionHandlerListener(projectErrorsMock);

    // then
    Assertions.assertThat(impl.projectApiErrors).isSameAs(projectErrorsMock);
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:12,代码来源:DownstreamNetworkExceptionHandlerListenerTest.java


示例15: constructor_throws_IllegalArgumentException_if_passed_null_listener_list

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void constructor_throws_IllegalArgumentException_if_passed_null_listener_list() {
    // expect
    new ApiExceptionHandlerBase(mock(ProjectApiErrors.class), null, ApiExceptionHandlerUtils.DEFAULT_IMPL) {
        @Override
        protected Object prepareFrameworkRepresentation(
            DefaultErrorContractDTO errorContractDTO, int httpStatusCode, Collection rawFilteredApiErrors,
            Throwable originalException, RequestInfoForLogging request) {
            return null;
        }
    };
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:13,代码来源:ApiExceptionHandlerBaseTest.java


示例16: constructor_throws_IllegalArgumentException_if_passed_null_apiExceptionHandlerUtils

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void constructor_throws_IllegalArgumentException_if_passed_null_apiExceptionHandlerUtils() {
    // expect
    new ApiExceptionHandlerBase(mock(ProjectApiErrors.class), singletonList(new GenericApiExceptionHandlerListener()), null) {
        @Override
        protected Object prepareFrameworkRepresentation(
            DefaultErrorContractDTO errorContractDTO, int httpStatusCode, Collection rawFilteredApiErrors,
            Throwable originalException, RequestInfoForLogging request) {
            return null;
        }
    };
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:13,代码来源:ApiExceptionHandlerBaseTest.java


示例17: mock

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Test
public void handleExceptionShouldUseGenericServiceErrorIfProjectApiErrorsDotGetSublistContainingOnlyHttpStatusCodeSomehowReturnsNull() {
    ProjectApiErrors mockProjectApiErrors = mock(ProjectApiErrors.class);
    doReturn(42).when(mockProjectApiErrors).determineHighestPriorityHttpStatusCode(anyCollection());
    doReturn(null).when(mockProjectApiErrors).getSublistContainingOnlyHttpStatusCode(anyCollection(), anyInt());
    doReturn(BarebonesCoreApiErrorForTesting.GENERIC_SERVICE_ERROR).when(mockProjectApiErrors).getGenericServiceError();

    ApiExceptionHandlerBase<TestDTO> handler = spy(new TestApiExceptionHandler(mockProjectApiErrors));

    List<Pair<String, String>> extraDetailsForLogging = new ArrayList<>();
    ErrorResponseInfo<TestDTO> testDto = handler.doHandleApiException(singletonSortedSetOf(CUSTOM_API_ERROR), extraDetailsForLogging,
                                                                      null, new Exception(), reqMock);
    assertThat(testDto.frameworkRepresentationObj.erv.errors.size(), is(1));
    assertThat(testDto.frameworkRepresentationObj.erv.errors.get(0).code, is(mockProjectApiErrors.getGenericServiceError().getErrorCode()));
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:16,代码来源:ApiExceptionHandlerBaseTest.java


示例18: TestApiExceptionHandler

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
private TestApiExceptionHandler(ProjectApiErrors projectApiErrorsToUse) {
    super(projectApiErrorsToUse,
        Arrays.asList(
            new GenericApiExceptionHandlerListener(),
            new ServersideValidationErrorHandlerListener(testProjectApiErrors, ApiExceptionHandlerUtils.DEFAULT_IMPL),
            new DownstreamNetworkExceptionHandlerListener(testProjectApiErrors),
            new CustomExceptionOfDoomHandlerListener()),
        ApiExceptionHandlerUtils.DEFAULT_IMPL);
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:10,代码来源:ApiExceptionHandlerBaseTest.java


示例19: Jersey2WebApplicationExceptionHandlerListener

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
/**
 * @param projectApiErrors The {@link ProjectApiErrors} that should be used by this instance when finding {@link
 *                         ApiError}s. Cannot be null.
 * @param utils The {@link ApiExceptionHandlerUtils} that should be used by this instance.
 */
@Inject
public Jersey2WebApplicationExceptionHandlerListener(ProjectApiErrors projectApiErrors,
                                                     ApiExceptionHandlerUtils utils) {
    if (projectApiErrors == null)
        throw new IllegalArgumentException("ProjectApiErrors cannot be null");

    if (utils == null)
        throw new IllegalArgumentException("ApiExceptionHandlerUtils cannot be null");

    this.projectApiErrors = projectApiErrors;
    this.utils = utils;
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:18,代码来源:Jersey2WebApplicationExceptionHandlerListener.java


示例20: Jersey2ApiExceptionHandler

import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors; //导入依赖的package包/类
@Inject
public Jersey2ApiExceptionHandler(ProjectApiErrors projectApiErrors,
                                  Jersey2ApiExceptionHandlerListenerList apiExceptionHandlerListenerList,
                                  ApiExceptionHandlerUtils apiExceptionHandlerUtils,
                                  JaxRsUnhandledExceptionHandler jaxRsUnhandledExceptionHandler) {

    super(projectApiErrors, apiExceptionHandlerListenerList.listeners, apiExceptionHandlerUtils, jaxRsUnhandledExceptionHandler);
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:9,代码来源:Jersey2ApiExceptionHandler.java



注:本文中的com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PageType类代码示例发布时间:2022-05-15
下一篇:
Java OpenblocksFrameListener类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap