public class Foo {
public A getSomething() {
Properties file = loadProperties().getProperty(something);
}
public static Properties loadProperties() {
Properties properties = new Properties();
properties.load(Foo.class.getClassLoader().getResourceAsStream("id"));
}
return properties;
}
What I did is:
@InjectMocks
Foo foo = new Foo();
@Test
public void test() {
MockitoAnnotations.initMocks(this);
Properties properties = Mockito.mock(Properties.class);
Mockito.doNothing().when(properties).load(new FileInputStream("application.properties")
foo.getSomething();
}
It throws null pointer exception in properties.load method. Any help would be appreciated.
Thank you.