I have an issue in mocking my rest web service's, one of the private methods.
So the flow, goes something like this,
JobController --> JobService --> createJob()
So here, in createJob() of my JobService, I will do another rest call to create a job, because job creation is hosted by someother team and I want to use the API exposed by them.
Before making a call to the API, I will create my payload, by calling prepareJobEntity(), which is a private method.
So, in my test case, this is the way I am trying to mock.
My TestDataProvider looks something like this.
The issue I am facing is,
Argument(s) are different! Wanted:
-> at com.JobControllerTest.testCreateJob_whenJobDoesNotExist(JobControllerTest.java:90)
Actual invocation has different arguments:
-> at com.JobService.createProcessingJob(JobService.java:61)
I understand both the job instances are different, and that is the reason I am getting this issue. But, kind of confused on how to solve this. Can anyone please throw some light on this?
What's happening is that your Job class does not have an equals method, so it is using the default one from Object.
Since the Job you create in the test and the Job created in the code are not the same object then the mock check for 'schedulerManager.create(job)' will fail as the two jobs are not equal.