@Test
public void testBeforeSlingInstall() throws Exception {

    final Invocable delegate = mock(Invocable.class);
    final ScriptProgressCheck.ScriptHelper helper = new ScriptProgressCheck.ScriptHelper();
    final ScriptProgressCheck check = new ScriptProgressCheck(delegate, helper, null);
    final List<Map.Entry<String, Object[]>> argRecord = new ArrayList<>();
    doAnswer(call -> argRecord.add(toEntry(call.getArgument(0), call.getArguments())))
            .when(delegate).invokeFunction(anyString(), any());
    final PackageId arg1 = PackageId.fromString("my_packages:example:1.0");
    final SlingInstallable arg2 = mock(SlingInstallable.class);
    final Session arg3 = mock(Session.class);
    check.beforeSlingInstall(arg1, arg2, arg3);
    Map.Entry<String, Object[]> call = argRecord.stream()
            .filter(entry -> "beforeSlingInstall".equals(entry.getKey()) && entry.getValue().length == 4).findFirst()
            .orElse(null);
    assertNotNull("expect call for beforeSlingInstall", call);
    assertSame("same arg1", arg1, call.getValue()[1]);
    assertSame("same arg2", arg2, call.getValue()[2]);
    assertSame("same arg3", arg3, call.getValue()[3]);
}