I want to mock profileRepository.save()
from the method:
public ProfileEty saveProfile(){
UserEty userEty = new UserEty();
ProfileEty profile = new ProfileEty();
SettingsEty settingsEty = new SettingsEty();
CustomizeEty customizeEty = new CustomizeEty();
profile.setUser(userEty);
profile = profileRepository.save(profile);
return profile;
}
If I try this in my Test
@Test
public void should_saveProfile(){
//Given
when(profileRepository.save(SOME_PROFILE)).thenReturn(SOME_PROFILE);
}
Where SOME_PROFILE is equals to:
public static final ProfileEty SOME_PROFILE = new ProfileEty();
The Profile
returned from the mock profileRepository
won´t be the same as the one created in the method saveProfile()
How to make sure that I am working with the same Profile
, or how to perform this kind of cases?