I'm using FnProject now and I'm using external dependencies to access external resources and I'm trying to mock to test the function without dependencies in it. How should I mock my external resource?
public class FunctionTest {
@Rule
public final FnTestingRule testing = FnTestingRule.createDefault();
@Test
public void shouldReturnGreeting() {
testing.givenEvent().withBody("{\"data\":123}").enqueue();
testing.thenRun(Function.class, "handleRequest");
FnResult result = testing.getOnlyResult();
assertEquals("OK", result.getBodyAsString());
}
}
public class Function {
public ExternalResource getExternalResource() {
return new ExternalResource(); // how to mock this?
}
public String handleRequest(String inputData) {
var externalResource = getExternalResource();
externalResource.doSomething();
return "OK";
}
}
Hi team,
I'm using FnProject now and I'm using external dependencies to access external resources and I'm trying to mock to test the function without dependencies in it. How should I mock my external resource?