Using mock at this step in ChallengeServiceTest.java is not appropriate since it will return null after running JPA repo methods like save etc. It should use @SpringBootTest and @Autowired to inject beans to test the service layer.
@SpringBootTest
public class ChallengeServiceTest {
private ChallengeService challengeService;
// @Mock
@Autowired
private UserRepository userRepository;
// @Mock
@Autowired
private ChallengeAttemptRepository attemptRepository;
......
}
Using mock at this step in ChallengeServiceTest.java is not appropriate since it will return null after running JPA repo methods like save etc. It should use
@SpringBootTestand@Autowiredto inject beans to test the service layer.