How to make spring boot @Value fields inject the values from properties?
authService contains 2 fields:
both of them are set to null for some reason. any idea why? applicaiton test properties indeed contains the 2 pairs

@ExtendWith(MockitoExtension.class)
@TestPropertySource("classpath:application-test.properties")
class AuthServiceTests {
@Mock
private UserService userService;
@InjectMocks
private AuthService authService;
@Test
void testRegisterUser() {
when(userService.existsByEmail("[email protected]")).thenReturn(false);
when(userService.existsByEmail("[email protected]")).thenReturn(true);
assertThat(authService.register("username", "[email protected]", "Password1"))
.isNotNull();
assertThatThrownBy(() -> authService.register("username", "[email protected]", "Password1"))
.isInstanceOf(UserAlreadyExistsException.class);
}
}@ExtendWith(MockitoExtension.class)
@TestPropertySource("classpath:application-test.properties")
class AuthServiceTests {
@Mock
private UserService userService;
@InjectMocks
private AuthService authService;
@Test
void testRegisterUser() {
when(userService.existsByEmail("[email protected]")).thenReturn(false);
when(userService.existsByEmail("[email protected]")).thenReturn(true);
assertThat(authService.register("username", "[email protected]", "Password1"))
.isNotNull();
assertThatThrownBy(() -> authService.register("username", "[email protected]", "Password1"))
.isInstanceOf(UserAlreadyExistsException.class);
}
}@Value("${notecz.auth.jwt.expire}")
private Long validFor;
@Value("${notecz.auth.jwt.secret}")
private String secret;@Value("${notecz.auth.jwt.expire}")
private Long validFor;
@Value("${notecz.auth.jwt.secret}")
private String secret;