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 检测不到第二个的使用。
电子手机配件网站源码是一个响应式的织梦网站模板,软件兼容主流浏览器,且可以在PC端和手机端中进行浏览。模板包含安装说明,并包含测试数据。本模板基于DEDECms 5.7 UTF-8设计,需要GBK版本的请自己转换。模板安装方法:1、下载最新的织梦dedecms5.7 UTF-8版本。2、解压下载的织梦安装包,得到docs和uploads两个文件夹,请将uploads里面的所有文件和文件夹上传到你的
0
Observation modifiedObservation = studentResourceHandler.setObservationCode(correctObservation, coding);
查看主代码块的结构,理想情况下您应该调用第二个定义(有 4 个参数),该定义又调用另一个定义。
以上就是无法解析方法 - Intellij的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号