@Test public void exceptionToStatus() { _assertStatus(HttpStatus.NOT_FOUND, new BankService.ClientNotFoundExc()); _assertStatus(HttpStatus.NOT_FOUND, new Client.NotManagedAccountExc()); _assertStatus(HttpStatus.FORBIDDEN, new Client.NotOwnerExc()); _assertStatus(HttpStatus.FORBIDDEN, new Client.WithoutRightExc()); _assertStatus(HttpStatus.BAD_REQUEST, new Amount.RangeExc()); _assertStatus(HttpStatus.BAD_REQUEST, new BankService.DeleteExc()); _assertStatus(HttpStatus.BAD_REQUEST, new BankService.UsernameExc()); _assertStatus(HttpStatus.BAD_REQUEST, new Client.AmountExc()); _assertStatus(HttpStatus.BAD_REQUEST, new Client.DoubleManagerExc()); _assertStatus(HttpStatus.BAD_REQUEST, new Client.MinimumBalanceExc()); _assertStatus(HttpStatus.BAD_REQUEST, new ClientCreateWithIdExc()); _assertStatus(HttpStatus.INTERNAL_SERVER_ERROR, new IllegalAccessException()); }
HttpStatus exceptionToStatus(final Exception exc) { if (exc instanceof BankService.ClientNotFoundExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotManagedAccountExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotOwnerExc) { return HttpStatus.FORBIDDEN; } if (exc instanceof Client.WithoutRightExc) { return HttpStatus.FORBIDDEN; } final String excClassName = exc.getClass().getName(); if (excClassName.startsWith(restInterfacePackagePrefix) || excClassName.startsWith(domainPackagePrefix)) { return HttpStatus.BAD_REQUEST; } return HttpStatus.INTERNAL_SERVER_ERROR; }
ExceptionAdvice { HttpStatus exceptionToStatus(final Exception exc) { if (exc instanceof BankService.ClientNotFoundExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotManagedAccountExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotOwnerExc) { return HttpStatus.FORBIDDEN; } if (exc instanceof Client.WithoutRightExc) { return HttpStatus.FORBIDDEN; } final String excClassName = exc.getClass().getName(); if (excClassName.startsWith(restInterfacePackagePrefix) || excClassName.startsWith(domainPackagePrefix)) { return HttpStatus.BAD_REQUEST; } return HttpStatus.INTERNAL_SERVER_ERROR; } }
ExceptionAdvice { HttpStatus exceptionToStatus(final Exception exc) { if (exc instanceof BankService.ClientNotFoundExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotManagedAccountExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotOwnerExc) { return HttpStatus.FORBIDDEN; } if (exc instanceof Client.WithoutRightExc) { return HttpStatus.FORBIDDEN; } final String excClassName = exc.getClass().getName(); if (excClassName.startsWith(restInterfacePackagePrefix) || excClassName.startsWith(domainPackagePrefix)) { return HttpStatus.BAD_REQUEST; } return HttpStatus.INTERNAL_SERVER_ERROR; }  }
ExceptionAdvice { HttpStatus exceptionToStatus(final Exception exc) { if (exc instanceof BankService.ClientNotFoundExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotManagedAccountExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotOwnerExc) { return HttpStatus.FORBIDDEN; } if (exc instanceof Client.WithoutRightExc) { return HttpStatus.FORBIDDEN; } final String excClassName = exc.getClass().getName(); if (excClassName.startsWith(restInterfacePackagePrefix) || excClassName.startsWith(domainPackagePrefix)) { return HttpStatus.BAD_REQUEST; } return HttpStatus.INTERNAL_SERVER_ERROR; }   }
ExceptionAdvice { HttpStatus exceptionToStatus(final Exception exc) { if (exc instanceof BankService.ClientNotFoundExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotManagedAccountExc) { return HttpStatus.NOT_FOUND; } if (exc instanceof Client.NotOwnerExc) { return HttpStatus.FORBIDDEN; } if (exc instanceof Client.WithoutRightExc) { return HttpStatus.FORBIDDEN; } final String excClassName = exc.getClass().getName(); if (excClassName.startsWith(restInterfacePackagePrefix) || excClassName.startsWith(domainPackagePrefix)) { return HttpStatus.BAD_REQUEST; } return HttpStatus.INTERNAL_SERVER_ERROR; }   static final String BASE_NAME; }