Я пытаюсь загрузить значение свойства из своего application-test.properties в тестах моего сервисного модуля (используя MockitoJUnitRunner.class), но оно всегда получает нулевое значение с помощью аннотации @Value.
@RunWith(MockitoJUnitRunner.class)
public class AlertQueryServiceImplTest {
@Value("${raw.path}")
private static String rawJson;
@InjectMocks
private AlertQueryServiceImpl alertQueryServiceImpl;
@Mock
private AlertCBDAOImpl alertCBDAOImpl;
private List<Alert> alertListExpected;
@Before
public void setUp() {
ReflectionTestUtils.setField(alertQueryServiceImpl, "url", "http://someurl");
alertListExpected = JsonUtils.
loadObjectList(Alert.class, JsonUtils.ALERTS_FILE);
assertFalse(alertListExpected.isEmpty());
}
@Test
public void shouldReturnAlerts() {
User userTest = new User("108998", "3000747091");
JsonDocument jsonDocExpected = JsonUtils.stringToJsonDocument(rawJson, userTest.getAssociatedBE());
when(alertCBDAOImpl.getDoc(userTest.getAssociatedBE())).thenReturn(jsonDocExpected);
when(alertCBDAOImpl.getAlerts(jsonDocExpected)).thenReturn(alertListExpected);
}
}
Как я могу загрузить raw.path
свойство в rawJson
поле?