I have written the following code to test a method within my code. To create the s3Event, I have a json file but when I use the class loader I am always returned a null exception. It could be possible I have the absolute path incorrect? I have attached an image to show the file pathway layout in case this is the mistake.
@Test
@DisplayName("Testing the handleRequest")
void testTheHandleRequest() throws URISyntaxException, IOException {
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(Objects.requireNonNull(classLoader.getResource("s3Event.json")).toURI());
S3Event s3Event = new ObjectMapper().readValue(file, S3Event.class);
Context context = null;
LambdaHandler lambdaHandler = new LambdaHandler();
assertEquals ("Finished handleRequest()", lambdaHandler.handleRequest(s3Event, null));
}