本文整理汇总了Java中com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors类的典型用法代码示例。如果您正苦于以下问题:Java ProjectApiErrors类的具体用法?Java ProjectApiErrors怎么用?Java ProjectApiErrors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectApiErrors类属于com.nike.backstopper.apierror.projectspecificinfo包,在下文中一共展示了ProjectApiErrors类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
};
}