How to call resolveFileFromResources function

My test cases are failing i know i am doing hard coding to call the resolveFileFromResources method but how to get the trades.json file without hard coded. In debug mode its args[0] but how to get the value of the args[0] in the runtime.

resultOfResolveFilePathArgs0 Add path of your trades file into this variable.

Okay so think about this.
mainreadfile function takes different argument.
First argument ,i.e., args[0] gave you the name while debugging.
And resolveFileFromResources takes filename as argument.
Try relating all of these things.

I understand but the thing is i don’t know how to extract value of args[0] using code . I tried String a=args[0] ; it doesn’t gives any result.

You need filename as argument in resolveFileFromResources function.
When you tried to debug, you know what value args[0] gave.
Dont try to think anything complex. You are in the right direction.
Try the gradlew and see if it gives output.

Yes i got the file name using args[0] which is xxx.json and i got all the test case successful in the local but as i push the code in the repository. It gives mainReadFile(),mainReadFileEdgecase() test case failed.

You need file and objectmapper look at the function provided in the class, their arguments and their return type

Try not to hardcode anything.
you already have different functions in the program itself that will return all the value you need

I think because of the hard code of the resolveFileFromResources(“xx.json”) it is giving me the test case failed.

Try implementing reverse engineering.
From where did you get your xxx.json file name.
We already discussed that in above comments.

i know i have to write some code which will give file name.
And in debug mode args[0] has that value but unable to extract that value .
File file = resolveFileFromResources(“trades.json”);
Not getting the logic that how to write that code to extract file name.

You dont have to extract filename. You have to take it as an argument.

I cant explain it more deeply as it may be considered as a direct answer.
But just simple logic to understand.
args is an string array and you have to put the first index value as resolveFileFromResources argument

Maybe anyone else on forum can explain you better.

The answer is already present in front of you. Have a break, and analyse again what you need to do, you know args[0] gives the file name you need, and you need to give that file name in resolveFileFromResources function, so what should you exactly pass as an argument to resolveFileFromResources funtion.
@visargdesai is right, it can’t be explained any more.

1 Like

Thanks alot , My mistake was that i was executing the program directly so it was giving me ArrayIndexOutOfBound .

Thanks After taking some break it really works.