There is a mock for a service below:
@TestConfiguration
public static class TestConfig {
@Bean
@Primary
public UserService userServiceBean() {
UserService mock = mock(UserService.class);
doReturn(12l).when(mock).getCompanyId();
return mock;
}
}
This affects other UT where I want to return some other companyId such as:
when(userService.getCompanyId()).thenReturn(155l); <-- this mock is not working
Thanks