Hey,
I am pretty much new to this JUnit testing thing :/ I tried a whole lot different methods, and none seemed to work.
Specially reading this docs: https://docs.spring.io/spring-boot/docs/...sting.html
I either suck at reading docs, or this one is not really complete or, I am just too stupid. So help me out :/
Im trying to test my services for now, and then try some other cool features in this area. But my tests just do not pass :O
This is the service Im trying to test: https://pastebin.com/C4VWMQFj
This is the service test: https://pastebin.com/H0LFq4Pe
This is Spring Boot application:
This is config:
As you can see from the pastebin, userRepository.save(user) returns null (assertion fails obviously) for some reason.
What am I doing wrong?
I am pretty much new to this JUnit testing thing :/ I tried a whole lot different methods, and none seemed to work.
Specially reading this docs: https://docs.spring.io/spring-boot/docs/...sting.html
I either suck at reading docs, or this one is not really complete or, I am just too stupid. So help me out :/
Im trying to test my services for now, and then try some other cool features in this area. But my tests just do not pass :O
This is the service Im trying to test: https://pastebin.com/C4VWMQFj
This is the service test: https://pastebin.com/H0LFq4Pe
This is Spring Boot application:
Code
@SpringBootApplication
public class Spotted {
public static void main(String[] args) {
SpringApplication.run(Spotted.class, args);
}
}This is config:
Code
@Configuration
public class SpottedConfig extends WebMvcConfigurerAdapter {
@Autowired
private AuthInterceptor authInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry){
registry.addInterceptor(authInterceptor).addPathPatterns("/**").excludePathPatterns("/user/r/**", "/user/l/**", "/user/cr/**", "/t/**");
}
}As you can see from the pastebin, userRepository.save(user) returns null (assertion fails obviously) for some reason.
What am I doing wrong?
Gopher



