I try to create/save a LabTestAttribute it throws a ConversionException exception. I am writing a unit test for one of our module named as common lab test module. Before going on the issue I will let know the structure of module code.
@shujaat, there is probably missing a @PropertyGetter annotated method for the property valueReference that you added. You may need to provide this method depending on your use case to silence this error.
@ruhanga, in openmrs BaseAttribute class we have the setter and getter for valueReference property, Take a look at the BaseAttribute Abstract Class
https://pastebin.com/x48RTGi0.
Thanks a bunch @dkayiwa, these methods as is didn’t work, but I got the point. We needed to explicitly define PropertyGetter/Setter to handle value in this case.
@tendomart did you take a look at this in your log?
Caused by: java.lang.NumberFormatException: For input string: "TestTask" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615) at org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.TaskDefinitionResource1_8.getByUniqueId(TaskDefinitionResource1_8.java:119)
@dkayiwa Yes I did , am not however certain why it throws a NumberFormatException yet i did provide the right params for this constructor TaskDefinition(java.lang.Integer id, java.lang.String name, java.lang.String description, java.lang.String taskClass)
public String getUuid() {
return RestTestConstants1_8.TASK_DEFINITION_UUID;
}
Necessarily designed to take in a string , if so then why do we have to parse in Non-Numeric **RestTestConstantsX_.UUID’**s then again type cast them to integers ?
I asked because trying to return a uuid as above a String , still requires an int , and failure to do so throws
java.lang.NumberFormatException: For input string: “266a2ff1-f0b1-45f4-ad04-2ce952a27920”
I did it but am still getting a String to Int Casting Error specifically java.lang.NumberFormatException
something like this java.lang.NumberFormatException: For input string: “0464edb8-4a6e-11eb-b378-0242ac130002” so that we can not return the TaskDefinition using a the provided String uuid , as per the requirement.
@dkayiwa looks like we need to provide OverLoad TaskDefinition in core to accept an Int .
public class TaskServiceWrapper2_4 extends TaskServiceWrapper {
public TaskDefinition getTaskByUuid(String uuid) {
return Context.getSchedulerService().getTaskByUuid(uuid);
}
}
Wrapper method injected at
public class TaskDefinitionResource2_4 extends TaskDefinitionResource1_8 {
private TaskServiceWrapper2_4 taskServiceWrapper = new TaskServiceWrapper2_4();
public void setTaskServiceWrapper(TaskServiceWrapper2_4 taskServiceWrapper) {
this.taskServiceWrapper = taskServiceWrapper;
}
.......
}