Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

409
Views
¿Cómo devolver el argumento, con el que se llamó al método simulado, como respuesta?

¿Es posible en Mockito devolver el objeto con el que se llamó al método simulado? Sin saber previamente qué objeto será.

 @Mock MyObjectRepository myObjectRepository; ... when(myObjectRepository.save(any(MyObject.class))) //save method returns normally MyObject.class object .thenReturn(\\the object that method was called with);

Quiero devolver el objeto que se pasa al método de guardado.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Lo siguiente debería funcionar:

 when(myObjectRepository.save(any(MyObject.class))) .then(AdditionalAnswers.returnsFirstArg());
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!