Weird Error during Test, cannot understand what it is checking for

I ran TiingoServiceTest in debugger mode and this was the generated stacktrace.

The assertion failed error implied my code had not cleared a test condition. As per the stacktrace, it originated from line 85 of the test file. I have gone through the test file and manually checked the values being tested by adding a breakpoint. All of them are empty.

My question is, what exactly is this section of code doing? I cannot understand that and without doing that I cannot see where my logic is failing. The same logic was working for me in Module 4 but its breaking here and I got no idea why that is happening, since I cannot understand what is being tested here. Please help.

@anand-crio @Rahul-Crio.do

I would suggest you to read a little about ArgumentCaptor in Mockito, and tell me your understanding. I will answer this query post that.

As far as I read, it is used to verify argument created inside the class, since it wasn’t passed and was only present in the class. But why would that fail for my code since I am build the uri inside TiingoService class which does uses multiple string variables, along with the restTemplate that is used, plus the result objects.

You got first part right, but another part of that is, it also checks whether the argument is created on specific mock call.
So for that, getForObject should be called. If it’s not getting called, then it will complain.

Thank you. I found the mistake.

@anand-crio sir, I am using getForObject() with String.Class. But still it’s failing why.

You need to use the first type, where it maps API response to string.