### Question:
PermReloadPermissionsFromFile implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { if (!accountWhitelistController.isPresent() && !nodesWhitelistController.isPresent()) { return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.PERMISSIONING_NOT_ENABLED); } try { accountWhitelistController.ifPresent(AccountLocalConfigPermissioningController::reload); nodesWhitelistController.ifPresent(NodeLocalConfigPermissioningController::reload); return new JsonRpcSuccessResponse(requestContext.getRequest().getId()); } catch (Exception e) { return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.ALLOWLIST_RELOAD_ERROR); } } PermReloadPermissionsFromFile(
      final Optional<AccountLocalConfigPermissioningController> accountWhitelistController,
      final Optional<NodeLocalConfigPermissioningController> nodesWhitelistController); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void whenBothControllersAreNotPresentMethodShouldReturnPermissioningDisabled() { JsonRpcResponse expectedErrorResponse = new JsonRpcErrorResponse(null, JsonRpcError.PERMISSIONING_NOT_ENABLED); method = new PermReloadPermissionsFromFile(Optional.empty(), Optional.empty()); JsonRpcResponse response = method.response(reloadRequest()); assertThat(response).isEqualToComparingFieldByField(expectedErrorResponse); }
@Test public void whenControllersReloadSucceedsMethodShouldReturnSuccess() { JsonRpcResponse response = method.response(reloadRequest()); verify(accountLocalConfigPermissioningController).reload(); verify(nodeLocalConfigPermissioningController).reload(); assertThat(response).isEqualToComparingFieldByField(successResponse()); }
@Test public void whenControllerReloadFailsMethodShouldReturnError() { doThrow(new RuntimeException()).when(accountLocalConfigPermissioningController).reload(); JsonRpcResponse expectedErrorResponse = new JsonRpcErrorResponse(null, JsonRpcError.ALLOWLIST_RELOAD_ERROR); JsonRpcResponse response = method.response(reloadRequest()); assertThat(response).isEqualToComparingFieldByField(expectedErrorResponse); }