Here are the examples of the java api org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
107 Examples
19
Source : ResponseEntityPro.java
with Apache License 2.0
from yujunhao8831
with Apache License 2.0
from yujunhao8831
public static <T> ResponseEnreplacedy<T> unprocessableEnreplacedy(final T body) {
return status(HttpStatus.UNPROCESSABLE_ENreplacedY, body);
}
19
Source : ResponseEntityPro.java
with Apache License 2.0
from yujunhao8831
with Apache License 2.0
from yujunhao8831
public static <T> ResponseEnreplacedy<T> unprocessableEnreplacedy(final T body, final String filterFields) {
if (null == filterFields || WILDCARD_ALL.equals(filterFields)) {
return unprocessableEnreplacedy(body);
}
return status(HttpStatus.UNPROCESSABLE_ENreplacedY, body, filterFields);
}
19
Source : ResponseEntityPro.java
with Apache License 2.0
from yujunhao8831
with Apache License 2.0
from yujunhao8831
public static ResponseEnreplacedy<String> unprocessableEnreplacedy() {
return status(HttpStatus.UNPROCESSABLE_ENreplacedY, HttpStatus.UNPROCESSABLE_ENreplacedY.getReasonPhrase());
}
19
Source : DefaultServerResponseBuilderTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void unprocessableEnreplacedy() {
ServerResponse response = ServerResponse.unprocessableEnreplacedy().build();
replacedertEquals(HttpStatus.UNPROCESSABLE_ENreplacedY, response.statusCode());
}
19
Source : StatusResultMatchers.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* replacedert the response status code is {@code HttpStatus.UNPROCESSABLE_ENreplacedY} (422).
*/
public ResultMatcher isUnprocessableEnreplacedy() {
return matcher(HttpStatus.UNPROCESSABLE_ENreplacedY);
}
19
Source : ReleasePathAdviceTraitTest.java
with MIT License
from tillias
with MIT License
from tillias
@Test
void handleSelfCircularException() {
final SelfCircularException exception = new SelfCircularException("Test message", aMicroserviceDto().withId(1L).withName("Test").build());
ResponseEnreplacedy<Problem> response = cut.handleSelfCircularException(exception, webRequest);
replacedertThat(response).isNotNull().extracting(HttpEnreplacedy::getBody).isNotNull();
replacedertThat(response.getStatusCodeValue()).isEqualTo(HttpStatus.UNPROCESSABLE_ENreplacedY.value());
replacedertThat(response.getBody()).isNotNull().extracting(Problem::getParameters, InstanceOfreplacedertFactories.map(String.clreplaced, Object.clreplaced)).contains(entry(ReleasePathAdviceTrait.EXCEPTION_KEY, exception.getClreplaced().getSimpleName()), entry(ReleasePathAdviceTrait.MESSAGE_KEY, "Test message"), entry("microserviceName", "Test"));
}
19
Source : AsyncResponseEntity.java
with Apache License 2.0
from quebic-source
with Apache License 2.0
from quebic-source
public static <T> AsyncResponseEnreplacedy<T> unprocessableEnreplacedy() {
return AsyncResponseEnreplacedy.status(HttpStatus.UNPROCESSABLE_ENreplacedY);
}
19
Source : UnprocessableEntityException.java
with Apache License 2.0
from provectus
with Apache License 2.0
from provectus
@Override
public HttpStatus getResponseStatusCode() {
return HttpStatus.UNPROCESSABLE_ENreplacedY;
}
19
Source : GlobalControllerExceptionHandler.java
with MIT License
from FAForever
with MIT License
from FAForever
@ExceptionHandler(ApiException.clreplaced)
@ResponseStatus(HttpStatus.UNPROCESSABLE_ENreplacedY)
@ResponseBody
public ErrorResponse processApiException(ApiException ex) {
log.debug("API exception", ex);
return createResponseFromApiException(ex, HttpStatus.UNPROCESSABLE_ENreplacedY);
}
19
Source : RestResponseEntityExceptionHandler.java
with Apache License 2.0
from epam
with Apache License 2.0
from epam
// TODO: create better exception handling
@ExceptionHandler({ IllegalArgumentException.clreplaced, IllegalStateException.clreplaced })
protected ResponseEnreplacedy<Object> unpocessableEnreplacedy(RuntimeException ex, WebRequest request) {
return handle(ex, MessageResponse.with(latestNotBlankMessageOrDefault(ex)), request, HttpStatus.UNPROCESSABLE_ENreplacedY);
}
19
Source : JobConfigurationController.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
@Override
protected void prePatchEnreplacedy(JobConfiguration jobConfiguration) throws WebMessageException {
checkConfigurable(jobConfiguration, HttpStatus.UNPROCESSABLE_ENreplacedY, "Job %s is a system job that cannot be modified.");
}
19
Source : JobConfigurationController.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
@Override
protected void preDeleteEnreplacedy(JobConfiguration jobConfiguration) throws WebMessageException {
checkConfigurable(jobConfiguration, HttpStatus.UNPROCESSABLE_ENreplacedY, "Job %s is a system job that cannot be deleted.");
}
19
Source : JobConfigurationController.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
@Override
protected void preUpdateEnreplacedy(JobConfiguration before, JobConfiguration after) throws WebMessageException {
checkConfigurable(before, HttpStatus.UNPROCESSABLE_ENreplacedY, "Job %s is a system job that cannot be modified.");
checkConfigurable(after, HttpStatus.CONFLICT, "Job %s can not be changed into a system job.");
}
19
Source : WebErrorHandlersIT.java
with Apache License 2.0
from alimate
with Apache License 2.0
from alimate
@Test
public void annotatedException_ShouldBeHandledProperly() {
contextRunner.run(ctx -> {
WebErrorHandlers errorHandlers = ctx.getBean(WebErrorHandlers.clreplaced);
SomeException exception = new SomeException(10, 12);
// Without locale
HttpError error = errorHandlers.handle(exception, null, null);
replacedertThat(error.getHttpStatus()).isEqualTo(HttpStatus.UNPROCESSABLE_ENreplacedY);
replacedertThat(error.getErrors()).containsOnly(cm("invalid_params", "Params are: 10, 12 and 42", arg("min", 10), arg("max", 12), arg("theAnswer", "42"), arg("notUsed", "123")));
// With locale
error = errorHandlers.handle(exception, null, Locale.CANADA);
replacedertThat(error.getHttpStatus()).isEqualTo(HttpStatus.UNPROCESSABLE_ENreplacedY);
replacedertThat(error.getErrors()).containsOnly(cm("invalid_params", "Params are: 10, 12 and 42", arg("min", 10), arg("max", 12), arg("theAnswer", "42"), arg("notUsed", "123")));
verifyPostProcessorsHasBeenCalled(ctx);
});
}
19
Source : WebErrorHandlersIT.java
with Apache License 2.0
from alimate
with Apache License 2.0
from alimate
private Object[] provideParamsForRefined() {
return p(p(new SymptomException(new SomeException(10, 11)), HttpStatus.UNPROCESSABLE_ENreplacedY, cm("invalid_params", "Params are: 10, 11 and 42", arg("min", 10), arg("max", 11), arg("theAnswer", "42"), arg("notUsed", "123"))), p(new SymptomException(null), HttpStatus.INTERNAL_SERVER_ERROR, cm("unknown_error", null)), p(new IllegalArgumentException(), HttpStatus.INTERNAL_SERVER_ERROR, cm("unknown_error", null)));
}
19
Source : PaymentControllerIT.java
with MIT License
from AlicanAkkus
with MIT License
from AlicanAkkus
@Test
void should_create_payment_when_balance_is_sufficient() {
doPayment(1L, "10.00", "10.00");
doPayment(1L, "5.50", "4.50");
doPayment(1L, "5.00", "4.50", HttpStatus.UNPROCESSABLE_ENreplacedY, "12");
doPayment(1L, "4.50", "0.00");
}
19
Source : DeleteSiteMemberSanityTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site consumer does not have permission to delete another member of the site")
public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception {
UserModel newUser = dataUser.createRandomTestUser("testUser");
newUser.setUserRole(UserRole.SiteCollaborator);
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId()));
}
19
Source : DeleteSiteMemberSanityTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site")
public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception {
UserModel newUser = dataUser.createRandomTestUser("testUser");
newUser.setUserRole(UserRole.SiteCollaborator);
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId()));
}
19
Source : DeleteSiteMemberSanityTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify site contributor does not have permission to delete another member of the site")
public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception {
UserModel newUser = dataUser.createRandomTestUser("testUser");
newUser.setUserRole(UserRole.SiteCollaborator);
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(siteModel).addPerson(newUser);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId()));
}
19
Source : DeleteSiteMemberFullTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a public site and response is 422")
public void userIsNotAbleToRemoveConsumerSiteMembershipFromPublicSite() throws Exception {
restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(publicSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId()));
}
19
Source : DeleteSiteMemberFullTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a moderated site and response is 422")
public void userIsNotAbleToRemoveConsumerSiteMembershipFromModeratedSite() throws Exception {
restClient.authenticateUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(moderatedSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId()));
}
19
Source : DeleteSiteMemberCoreTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from public site and response is 422")
public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPublicSite() throws Exception {
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(managerModel);
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel);
restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(publicSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId()));
}
19
Source : DeleteSiteMemberCoreTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from moderated site and response is 422")
public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromModeratedSite() throws Exception {
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(managerModel);
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel);
restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(moderatedSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId()));
}
19
Source : DeleteSiteMemberCoreTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member a moderated site and response is 422")
public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromModeratedSite() throws Exception {
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(secondUserModel);
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(userModel);
restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(moderatedSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, moderatedSiteModel.getId()));
}
18
Source : DefaultServerResponseBuilderTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void unprocessableEnreplacedy() {
Mono<ServerResponse> result = ServerResponse.unprocessableEnreplacedy().build();
StepVerifier.create(result).expectNextMatches(response -> HttpStatus.UNPROCESSABLE_ENreplacedY.equals(response.statusCode())).expectComplete().verify();
}
18
Source : ReleasePathAdviceTraitTest.java
with MIT License
from tillias
with MIT License
from tillias
@Test
void handleDuplicateDependencyException() {
final DuplicateDependencyException exception = new DuplicateDependencyException("Test message", aDependencyDto().withId(1L).withName("Test Dependency").withSource(aMicroserviceDto().withId(1L).build()).withTarget(aMicroserviceDto().withId(2L).build()).build());
ResponseEnreplacedy<Problem> response = cut.handleDuplicateDependencyException(exception, webRequest);
replacedertThat(response).isNotNull().extracting(HttpEnreplacedy::getBody).isNotNull();
replacedertThat(response.getStatusCodeValue()).isEqualTo(HttpStatus.UNPROCESSABLE_ENreplacedY.value());
replacedertThat(response.getBody()).isNotNull().extracting(Problem::getParameters, InstanceOfreplacedertFactories.map(String.clreplaced, Object.clreplaced)).contains(entry(ReleasePathAdviceTrait.EXCEPTION_KEY, exception.getClreplaced().getSimpleName()), entry(ReleasePathAdviceTrait.MESSAGE_KEY, "Test message"), entry("dependencyId", "1"), entry("dependencyName", "Test Dependency"));
}
18
Source : ReleasePathAdviceTraitTest.java
with MIT License
from tillias
with MIT License
from tillias
@Test
void handleCircularDependenciesException() {
final CircularDependenciesException exception = new CircularDependenciesException("Test message", new HashSet<>(Arrays.asList(aMicroserviceDto().withId(1L).withName("First").build(), aMicroserviceDto().withId(2L).withName("Second").build(), aMicroserviceDto().withId(3L).withName("Third").build())));
ResponseEnreplacedy<Problem> response = cut.handleCircularDependenciesException(exception, webRequest);
replacedertThat(response).isNotNull().extracting(HttpEnreplacedy::getBody).isNotNull();
replacedertThat(response.getStatusCodeValue()).isEqualTo(HttpStatus.UNPROCESSABLE_ENreplacedY.value());
replacedertThat(response.getBody()).isNotNull().extracting(Problem::getParameters, InstanceOfreplacedertFactories.map(String.clreplaced, Object.clreplaced)).contains(entry(ReleasePathAdviceTrait.EXCEPTION_KEY, exception.getClreplaced().getSimpleName()), entry(ReleasePathAdviceTrait.MESSAGE_KEY, "Test message"), entry("microservices", "First,Second,Third"));
}
18
Source : DefaultApiResultTransformer.java
with Apache License 2.0
from spring-avengers
with Apache License 2.0
from spring-avengers
public ApiResult handleMethodArgumentNotValidException(HttpServletRequest request, MethodArgumentNotValidException ex) {
String message = "Validating request parameter failed (" + ex.getBindingResult().getFieldErrors().stream().map(fieldError -> String.format("Field:%s Value:%s Reason:%s", fieldError.getField(), fieldError.getRejectedValue(), fieldError.getDefaultMessage())).collect(Collectors.joining("; ")) + ")";
return ApiResult.builder().time(System.currentTimeMillis()).success(false).code(String.valueOf(HttpStatus.UNPROCESSABLE_ENreplacedY.value())).data(null).error(ex.getClreplaced().getName()).message(message).path(request.getRequestURI()).build();
}
18
Source : DefaultServerResponseBuilderTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void unprocessableEnreplacedy() {
ServerResponse response = ServerResponse.unprocessableEnreplacedy().build();
replacedertThat(response.statusCode()).isEqualTo(HttpStatus.UNPROCESSABLE_ENreplacedY);
}
18
Source : TravelsJavaAPIExceptionHandler.java
with MIT License
from mariazevedo88
with MIT License
from mariazevedo88
/**
* Method that handles with a HttpMessageNotReadableException or JsonParseException and
* returns an Unprocessable Enreplacedy error with status code = 422.
*
* @author Mariana Azevedo
* @since 01/04/2020
*
* @param exception
* @return ResponseEnreplacedy<Response<T>>
*/
@ExceptionHandler(value = { HttpMessageNotReadableException.clreplaced, JsonParseException.clreplaced, NotParsableContentException.clreplaced })
protected ResponseEnreplacedy<Response<T>> handleMessageNotReadableException(Exception exception) {
Response<T> response = new Response<>();
response.addErrorMsgToResponse(exception.getLocalizedMessage());
return ResponseEnreplacedy.status(HttpStatus.UNPROCESSABLE_ENreplacedY).body(response);
}
18
Source : ConfigurationService.java
with MIT License
from lealceldeiro
with MIT License
from lealceldeiro
/**
* Saves various configurations at once.
*
* @param configs A {@link Map} of configurations. Every key in the Map is the configuration key, and the
* corresponding value is the configuration value.
* @throws NotFoundEnreplacedyException if any of the provided keys is not a valid key. Keys must correspond to any of
* the values in {@link ConfigKey} as String.
* @see ConfigKey
*/
public void saveConfig(final Map<String, Object> configs) throws NotFoundEnreplacedyException, GmsGeneralException {
if (configs.get("user") != null) {
try {
long id = Long.parseLong(configs.remove("user").toString());
saveConfig(configs, id);
} catch (NumberFormatException e) {
throw GmsGeneralException.builder().messageI18N(CONFIG_USER_PARAM_NUMBER).cause(e).finishedOK(false).httpStatus(HttpStatus.UNPROCESSABLE_ENreplacedY).build();
}
}
String uppercaseKey;
for (Map.Entry<String, Object> entry : configs.entrySet()) {
uppercaseKey = entry.getKey().toUpperCase(Locale.ENGLISH);
if (isValidKey(uppercaseKey) && uppercaseKey.endsWith(IN_SERVER)) {
switch(ConfigKey.valueOf(uppercaseKey)) {
case IS_MULTI_ENreplacedY_APP_IN_SERVER:
setIsMultiEnreplacedy(Boolean.parseBoolean(entry.getValue().toString()));
break;
case IS_USER_REGISTRATION_ALLOWED_IN_SERVER:
setUserRegistrationAllowed(Boolean.parseBoolean(entry.getValue().toString()));
break;
default:
throw new NotFoundEnreplacedyException(CONFIG_NOT_FOUND);
}
}
}
}
18
Source : DefaultControllerAdvice.java
with MIT License
from lealceldeiro
with MIT License
from lealceldeiro
// endregion
private ResponseEnreplacedy<Object> handleConstraintViolationException(final Exception ex, final WebRequest req) {
Object resBody = ExceptionUtil.getResponseBodyForConstraintViolationException(ex, msg, dc);
return handleExceptionInternal(ex, resBody, new HttpHeaders(), HttpStatus.UNPROCESSABLE_ENreplacedY, req);
}
18
Source : IdentitiesEndpoint_Updating_IT.java
with MIT License
from InnovateUKGitHub
with MIT License
from InnovateUKGitHub
// 422
@Test
public void onUpdateEmailWithInvalidJson() throws IOException {
withValidAuthentication().and().contentType(ContentType.JSON).body("{email:}").put(getBaseUrl() + "/idenreplacedies/" + uuidForUpdatingEmail + "/email").then().replacedertThat().statusCode(is(equalTo(HttpStatus.UNPROCESSABLE_ENreplacedY.value()))).body("message", is(not(nullValue()))).body("stacktrace", is(not(nullValue()))).body("message", containsString("was expecting double-quote to start field name")).body("stacktrace", containsString("HttpMessageNotReadableException"));
}
18
Source : IdentitiesEndpoint_Updating_IT.java
with MIT License
from InnovateUKGitHub
with MIT License
from InnovateUKGitHub
// 422
@Test
public void onUpdatePreplacedwordWithInvalidJson() throws IOException {
withValidAuthentication().and().contentType(ContentType.JSON).body("{preplacedword:}").put(getBaseUrl() + "/idenreplacedies/" + uuidForUpdatingPreplacedword + "/preplacedword").then().replacedertThat().statusCode(is(equalTo(HttpStatus.UNPROCESSABLE_ENreplacedY.value()))).body("message", is(not(nullValue()))).body("stacktrace", is(not(nullValue()))).body("message", containsString("was expecting double-quote to start field name")).body("stacktrace", containsString("HttpMessageNotReadableException"));
}
18
Source : IdentitiesEndpoint_Creating_IT.java
with MIT License
from InnovateUKGitHub
with MIT License
from InnovateUKGitHub
// 422
@Test
public void onCreationWithInvalidJson() throws IOException {
withValidAuthentication().and().contentType(ContentType.JSON).body("{email:[email protected]}").post(getBaseUrl() + "/idenreplacedies").then().replacedertThat().statusCode(is(equalTo(HttpStatus.UNPROCESSABLE_ENreplacedY.value()))).body("message", is(not(nullValue()))).body("stacktrace", is(not(nullValue()))).body("message", containsString("was expecting double-quote to start field name")).body("stacktrace", containsString("HttpMessageNotReadableException"));
}
18
Source : RestExceptionHandler.java
with GNU General Public License v3.0
from hantsy
with GNU General Public License v3.0
from hantsy
@Override
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
if (ex instanceof WebExchangeBindException) {
var webExchangeBindException = (WebExchangeBindException) ex;
log.debug("errors:" + webExchangeBindException.getFieldErrors());
var errors = new Errors("validation_failure", "Validation failed.");
webExchangeBindException.getFieldErrors().forEach(e -> errors.add(e.getField(), e.getCode(), e.getDefaultMessage()));
log.debug("handled errors::" + errors);
try {
exchange.getResponse().setStatusCode(HttpStatus.UNPROCESSABLE_ENreplacedY);
exchange.getResponse().getHeaders().setContentType(MediaType.APPLICATION_JSON);
var db = new DefaultDataBufferFactory().wrap(objectMapper.writeValueAsBytes(errors));
// write the given data buffer to the response
// and return a Mono that signals when it's done
return exchange.getResponse().writeWith(Mono.just(db));
} catch (JsonProcessingException e) {
exchange.getResponse().setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR);
return exchange.getResponse().setComplete();
}
} else if (ex instanceof PostNotFoundException) {
exchange.getResponse().setStatusCode(HttpStatus.NOT_FOUND);
// marks the response as complete and forbids writing to it
return exchange.getResponse().setComplete();
}
return Mono.error(ex);
}
18
Source : JobConfigurationController.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
@Override
protected void preUpdateItems(JobConfiguration jobConfiguration, IdentifiableObjects items) throws Exception {
checkConfigurable(jobConfiguration, HttpStatus.UNPROCESSABLE_ENreplacedY, "Job %s is a system job that cannot be modified.");
}
18
Source : WebMessageUtils.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
public static WebMessage unprocessableEnreplacedy(String message) {
return createWebMessage(message, Status.ERROR, HttpStatus.UNPROCESSABLE_ENreplacedY);
}
18
Source : WebMessageUtils.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
public static WebMessage unprocessableEnreplacedy(String message, String devMessage) {
return createWebMessage(message, devMessage, Status.ERROR, HttpStatus.UNPROCESSABLE_ENreplacedY);
}
18
Source : GlobalExceptionHandler.java
with MIT License
from anton-liauchuk
with MIT License
from anton-liauchuk
@ExceptionHandler(UnprocessableEnreplacedyException.clreplaced)
public ResponseEnreplacedy<ErrorResponse> onUnprocessableEnreplacedyException(UnprocessableEnreplacedyException e) {
var response = new ErrorResponse(e.getMessage());
return ResponseEnreplacedy.status(HttpStatus.UNPROCESSABLE_ENreplacedY).body(response);
}
18
Source : DeleteSiteMemberFullTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove contributor member of a public site and response is 422")
public void userIsNotAbleToRemoveContributorSiteMembershipFromPublicSite() throws Exception {
restClient.authenticateUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPublicSite.getOneUserWithRole(UserRole.SiteContributor)).deleteSiteMember(publicSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, publicSiteModel.getId()));
}
18
Source : DeleteSiteMemberFullTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove consumer member of a private site and response is 422")
public void userIsNotAbleToRemoveConsumerSiteMembershipFromPrivateSite() throws Exception {
restClient.authenticateUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingUser(usersWithRolesPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).deleteSiteMember(privateSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId()));
}
18
Source : DeleteSiteMemberCoreTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove admin membership from private site and response is 422")
public void regularUserIsNotAbleToRemoveAdminSiteMembershipFromPrivateSite() throws Exception {
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(managerModel);
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel);
restClient.authenticateUser(userModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMember(privateSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId()));
}
18
Source : DeleteSiteMemberCoreTests.java
with GNU Lesser General Public License v3.0
from Alfresco
with GNU Lesser General Public License v3.0
from Alfresco
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a regular member of a private site and response is 422")
public void regularUserIsNotAbleToRemoveRegularUserSiteMembershipFromPrivateSite() throws Exception {
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(userModel);
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(secondUserModel);
restClient.authenticateUser(secondUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(privateSiteModel);
restClient.replacedertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENreplacedY).replacedertLastError().containsSummary(String.format(RestErrorModel.NOT_SUFFICIENT_PERMISSIONS, privateSiteModel.getId()));
}
17
Source : PrivilegeManagementAccessControlServiceIT.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
public void testBatchCreateResourcesEmptyList() {
List<BaseResource> resources = new ArrayList<BaseResource>();
try {
this.acsAdminRestTemplate.postForEnreplacedy(this.acsUrl + PrivilegeHelper.ACS_RESOURCE_API_PATH, new HttpEnreplacedy<>(resources, this.zone1Headers), BaseResource[].clreplaced);
} catch (HttpClientErrorException e) {
replacedert.replacedertEquals(e.getStatusCode(), HttpStatus.UNPROCESSABLE_ENreplacedY);
return;
}
replacedert.fail("Expected unprocessable enreplacedy http client error.");
}
17
Source : PrivilegeManagementAccessControlServiceIT.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
public void testBatchCreateSubjectsEmptyList() {
List<BaseSubject> subjects = new ArrayList<BaseSubject>();
try {
this.acsAdminRestTemplate.postForEnreplacedy(this.acsUrl + PrivilegeHelper.ACS_SUBJECT_API_PATH, new HttpEnreplacedy<>(subjects, this.zone1Headers), BaseSubject[].clreplaced);
} catch (HttpClientErrorException e) {
replacedert.replacedertEquals(e.getStatusCode(), HttpStatus.UNPROCESSABLE_ENreplacedY);
return;
}
replacedert.fail("Expected unprocessable enreplacedy http client error.");
}
17
Source : PrivilegeManagementAccessControlServiceIT.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test(dataProvider = "invalidSubjectPostProvider")
public void testPostSubjectNegativeCases(final BaseSubject subject, final String endpoint) {
try {
this.privilegeHelper.postMultipleSubjects(this.acsAdminRestTemplate, endpoint, this.zone1Headers, subject);
} catch (HttpClientErrorException e) {
replacedert.replacedertEquals(e.getStatusCode(), HttpStatus.UNPROCESSABLE_ENreplacedY);
return;
} catch (Exception e) {
replacedert.fail("Unable to create subject.");
}
replacedert.fail("Expected Unprocessible Enreplacedy status code in testPostSubjectNegativeCases");
}
17
Source : PrivilegeManagementAccessControlServiceIT.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test(dataProvider = "invalidResourcePostProvider")
public void testPostResourceNegativeCases(final BaseResource resource, final String endpoint) {
try {
this.privilegeHelper.postResources(this.acsAdminRestTemplate, endpoint, this.zone1Headers, resource);
} catch (HttpClientErrorException e) {
replacedert.replacedertEquals(e.getStatusCode(), HttpStatus.UNPROCESSABLE_ENreplacedY);
return;
} catch (Exception e) {
replacedert.fail("Unable to create resource.");
}
replacedert.fail("Expected UnprocessibleEnreplacedy status code in testPostResourceNegativeCases");
}
17
Source : AccessControlServiceIT.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test(dataProvider = "endpointProvider")
public void testPolicyCreationJsonSchemaInvalidPolicySet(final String endpoint) throws Exception {
String testPolicyName = "";
try {
String policyFile = "src/test/resources/invalid-json-schema-policy-set.json";
testPolicyName = this.policyHelper.setTestPolicy(this.acsitSetUpFactory.getAcsZoneAdminRestTemplate(), this.acsitSetUpFactory.getZone1Headers(), endpoint, policyFile);
} catch (HttpClientErrorException e) {
this.acsTestUtil.replacedertExceptionResponseBody(e, "JSON Schema validation");
replacedert.replacedertEquals(e.getStatusCode(), HttpStatus.UNPROCESSABLE_ENreplacedY);
return;
}
this.policyHelper.deletePolicySet(this.acsitSetUpFactory.getAcsZoneAdminRestTemplate(), this.acsitSetUpFactory.getAcsUrl(), testPolicyName, this.acsitSetUpFactory.getZone1Headers());
replacedert.fail("testPolicyCreationInValidPolicy should have failed");
}
17
Source : AccessControlServiceIT.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test(dataProvider = "endpointProvider")
public void testPolicyCreationInValidWithBadPolicySetNamePolicy(final String endpoint) throws Exception {
String testPolicyName = "";
try {
String policyFile = "src/test/resources/policy-set-with-only-name-effect.json";
testPolicyName = this.policyHelper.setTestPolicy(this.acsitSetUpFactory.getAcsZoneAdminRestTemplate(), this.acsitSetUpFactory.getZone1Headers(), endpoint, policyFile);
} catch (HttpClientErrorException e) {
this.acsTestUtil.replacedertExceptionResponseBody(e, "is not URI friendly");
replacedert.replacedertEquals(e.getStatusCode(), HttpStatus.UNPROCESSABLE_ENreplacedY);
return;
}
this.policyHelper.deletePolicySet(this.acsitSetUpFactory.getAcsZoneAdminRestTemplate(), this.acsitSetUpFactory.getAcsUrl(), testPolicyName, this.acsitSetUpFactory.getZone1Headers());
replacedert.fail("testPolicyCreationInValidPolicy should have failed");
}
See More Examples