mercredi 21 mars 2018

How can I mock bean returning its own parameter?

I have a repository class something like ...

public class StuffRepository {
    public Stuff save(Stuff v);
}

I want to make a mock with @MockBean returning first parameter v. How can I do that?

@MockBean
private StuffRepository stuffRepository;

public void test() {
    given(stuffRepository.save(??)).willReturn(??);
}

Aucun commentaire:

Enregistrer un commentaire