In my maven java project, I have a directory with files:
src/test/resources/data/files/test.txt
this is a test file under test resources.
I have a class that looks for the file if it is available:
public class MyPoller{
    private boolean isFileAvailable(String file) {
        try {
            ClassPathResource classPathResource = new ClassPathResource(file);
            boolean exists = Files.exists(Paths.get(classPathResource.getFile().getPath()));
            if (exists) {
                FileTime modFileTime = Files.getLastModifiedTime(Paths.get(classPathResource.getFile().getPath()));
                long modFileMinutes = modFileTime.to(TimeUnit.MINUTES);
                long minutes = FileTime.from(Instant.now()).to(TimeUnit.MINUTES);
                return minutes - modFileMinutes >= 5;
            }
        } catch (IOException e) {
            LOGGER.error("Failed to check file is available", e);
            return false;
        }
        return false;
    }
}
It uses org.springframework.core.io.ClassPathResource;
From my cucumber tests (feature files) I pass the file path to isFileAvailable() as data\files\test.txt and the file is found and returns true and the test is successful.
However, when I execute mvn clean test, the condition in the method is failing and my build is not successful. I am not sure what the issue is and if I have missed something.
