There is a private method in a springBatch Beans. configuration class.
@Slf4j
public class EodDataDumpSpringBatchConfig {
private Resource getWriterResource(StepExecution stepExecution, Storage storage) {
String chunkUri = stepExecution.getJobParameters().getString(EodDataDumpConstants.CHUNK_URI);
String fileUri = chunkUri + stepExecution.getStepName();
Resource resource = new GoogleStorageResource(storage, fileUri);
return resource;
}
....
}
I am writing a springBatchTest:
@SpringBatchTest
@EnableAutoConfiguration
@SpringJUnitConfig({EodDataDumpSpringBatchConfig.class})
@ExtendWith(MockitoExtension.class)
@TestPropertySource(locations = "classpath:application.properties")
@MockitoSettings(strictness = Strictness.LENIENT)
public class EodDataDumpSpringBatchTest {
@Value("file:src/test/resources/storageFile.csv")
private Resource resource;
@Test
public void dataDumpJobEndToEndTest() throws Exception {
}
}
I want to mock the private method in when().thenReturn statement.
What I mean is, when any method calls that private method it should get a mocked Resource.
I tried:
- ReflectionUtils
- PoweMockit