首页 > Java > 正文

无法解析方法 - Intellij

WBOY
发布: 2024-02-22 14:07:06
转载
1791人浏览过

php小编鱼仔为您介绍本文主题:java编程中常见问题解答。今天我们将讨论intellij开发环境中常见的问题之一:无法解析方法。在java开发过程中,遇到无法解析方法的情况可能会让人头疼,但实际上很可能只是一个小问题。接下来,我们将为您详细解析可能导致这一问题的原因,并提供解决方法,帮助您更顺利地进行编程工作。

问题内容

试图找出为什么我在第二种方法中收到“setobservationcode is neverused”错误。第二个片段显示了单元测试的使用位置。通过单元测试,它给我一个“无法解析“resourcehandler”中的方法“setobservationcode”错误。我看到一些人说他们通过使缓存无效并重新启动来解决该错误,但这对我来说并不成功。

public class ResourceHandlerTest extends TestCase {

    FhirContext ctx = null;
    IParser parser = null;

    // Other methods...

    public String getId(Resource resource) {
        if (resource.getIdElement() != null) {
            // Use IdType to extract the ID without additional details such as base URL or resource type.
            IdType idType = resource.getIdElement();
            return idType.getIdPart();
        } else {
            // Handle the case where the resource does not have an ID.
            return null; // Or throw an exception, depending on your requirements.
        }
    }

    public Observation setObservationCode(Observation observation, Coding coding) {
        if (observation.getCode() == null) {
            observation.setCode(new CodeableConcept().addCoding(coding));
        } else {
            observation.getCode().addCoding(coding);
        }
        return observation;
    }

    
public Observation setObservationCode(Observation observation, Coding coding) {
            if (observation.getCode() == null) {
                observation.setCode(new CodeableConcept().addCoding(coding));
            } else {
                observation.getCode().addCoding(coding);
            }
            return observation;
        }
    
      public Observation setObservationCode(Observation observation, String system, String code, String display) {
            System.out.println("Debug: Observation Before - " + observation);
    
            System.out.println("Debug: System - " + system);
            System.out.println("Debug: Code - " + code);
            System.out.println("Debug: Display - " + display);
    
            Coding coding = new Coding().setSystem(system).setCode(code).setDisplay(display);
    
            return setObservationCode(observation, coding);
        }

-----------------------------------------------------------------------------------------------

    public void testSetObservationCode() throws Exception {
            if (ctx == null) ctx = FhirContext.forR4();
            if (parser == null) parser = ctx.newJsonParser();
    
            String observationJsonFile = "src/resources/observation.json";
            String observationJson = "";
            try {
                observationJson = new String(Files.readAllBytes(Paths.get(observationJsonFile)));
            }
            catch (Exception e) { System.err.println("Failed to read observation.json file."); }
    
            Observation correctObservation = parser.parseResource(Observation.class, observationJson);
    
            ResourceHandler studentResourceHandler = new ResourceHandler();
    
            String expectedSystem = "http://example.com/system";
            String expectedCode = "12345";
            String expectedDisplay = "Test Code";
    
            Coding coding = new Coding().setSystem(expectedSystem).setCode(expectedCode).setDisplay(expectedDisplay);
            Observation modifiedObservation = studentResourceHandler.setObservationCode(correctObservation, coding);
    
            assertEquals(expectedSystem, modifiedObservation.getCode().getCodingFirstRep().getSystem());
            assertEquals(expectedCode, modifiedObservation.getCode().getCodingFirstRep().getCode());
            assertEquals(expectedDisplay, modifiedObservation.getCode().getCodingFirstRep().getDisplay());
    
        }
登录后复制

解决方法

您在测试中调用了第一个方法,但没有调用第二个方法。

测试中最后一行的第 4 行有 2 个参数,这是第一个参数。因此 intellij 检测不到第二个的使用。

电子手机配件网站源码1.0
电子手机配件网站源码1.0

电子手机配件网站源码是一个响应式的织梦网站模板,软件兼容主流浏览器,且可以在PC端和手机端中进行浏览。模板包含安装说明,并包含测试数据。本模板基于DEDECms 5.7 UTF-8设计,需要GBK版本的请自己转换。模板安装方法:1、下载最新的织梦dedecms5.7 UTF-8版本。2、解压下载的织梦安装包,得到docs和uploads两个文件夹,请将uploads里面的所有文件和文件夹上传到你的

电子手机配件网站源码1.0 0
查看详情 电子手机配件网站源码1.0
Observation modifiedObservation = studentResourceHandler.setObservationCode(correctObservation, coding);
登录后复制

查看主代码块的结构,理想情况下您应该调用第二个定义(有 4 个参数),该定义又调用另一个定义。

以上就是无法解析方法 - Intellij的详细内容,更多请关注php中文网其它相关文章!

相关标签:
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:stackoverflow网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号