ScriptProgressCheck implements ProgressCheck { @Override public void identifyEmbeddedPackage(final PackageId packageId, final PackageId parentId, final EmbeddedPackageInstallable slingInstallable) { guardHandler(INVOKE_ON_IDENTIFY_EMBEDDED_PACKAGE, handle -> handle.apply(packageId, parentId, slingInstallable)); } ScriptProgressCheck(final @NotNull Invocable script,
                        final @NotNull ScriptHelper helper,
                        final @Nullable URL scriptUrl); @Override @Nullable String getResourceBundleBaseName(); @Override void setResourceBundle(final ResourceBundle resourceBundle); @Override String getCheckName(); @Override void simulateSling(final SlingSimulator slingSimulator, final Set<String> runModes); @Override void startedScan(); @Override void identifyPackage(final PackageId packageId, final File file); @Override void readManifest(final PackageId packageId, final Manifest manifest); @Override void beforeExtract(final PackageId packageId, final Session inspectSession,
                              final PackageProperties packageProperties, final MetaInf metaInf,
                              final List<PackageId> subpackages); @Override void importedPath(final PackageId packageId, final String path, final Node node,
                             final PathAction action); @Override void deletedPath(final PackageId packageId, final String path, final Session inspectSession); @Override void afterExtract(final PackageId packageId, final Session inspectSession); @Override void identifySubpackage(final PackageId packageId, final PackageId parentId); @Override void beforeSlingInstall(final PackageId lastPackage,
                                   final SlingInstallable slingInstallable,
                                   final Session inspectSession); @Override void identifyEmbeddedPackage(final PackageId packageId,
                                        final PackageId parentId,
                                        final EmbeddedPackageInstallable slingInstallable); @Override void appliedRepoInitScripts(final PackageId lastPackage,
                                       final List<String> scripts,
                                       final SlingInstallable slingInstallable,
                                       final Session inspectSession); @Override void afterScanPackage(final PackageId scanPackageId, final Session inspectSession); @Override void finishedScan(); @Override final Collection<Violation> getReportedViolations(); static ProgressCheckFactory createScriptCheckFactory(final @NotNull URL scriptUrl); @SuppressWarnings("WeakerAccess") static ProgressCheckFactory createScriptCheckFactory(final @NotNull String engineName,
                                                                final @NotNull URL scriptUrl); @SuppressWarnings("WeakerAccess") static ProgressCheckFactory createScriptCheckFactory(final @NotNull ScriptEngine engine,
                                                                final @NotNull URL scriptUrl); @SuppressWarnings("WeakerAccess") static ProgressCheckFactory createInlineScriptCheckFactory(final @NotNull String inlineScript,
                                                                      final @Nullable String inlineEngine); static final String DEFAULT_SCRIPT_ENGINE_EXTENSION; static final String BINDING_SCRIPT_HELPER; static final String BINDING_CHECK_CONFIG; static final String FILENAME_INLINE_SCRIPT; static final String INVOKE_ON_STARTED_SCAN; static final String INVOKE_ON_SIMULATE_SLING; static final String INVOKE_ON_IDENTIFY_PACKAGE; static final String INVOKE_ON_READ_MANIFEST; static final String INVOKE_ON_BEFORE_EXTRACT; static final String INVOKE_ON_IMPORTED_PATH; static final String INVOKE_ON_DELETED_PATH; static final String INVOKE_ON_AFTER_EXTRACT; static final String INVOKE_ON_IDENTIFY_SUBPACKAGE; static final String INVOKE_ON_BEFORE_SLING_INSTALL; static final String INVOKE_ON_IDENTIFY_EMBEDDED_PACKAGE; static final String INVOKE_ON_APPLIED_REPO_INIT_SCRIPTS; static final String INVOKE_ON_AFTER_SCAN_PACKAGE; static final String INVOKE_ON_FINISHED_SCAN; static final String INVOKE_GET_CHECK_NAME; }
@Test public void testIdentifyEmbeddedPackage() 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 PackageId arg2 = PackageId.fromString("my_packages:other-example:1.0"); final EmbeddedPackageInstallable arg3 = new EmbeddedPackageInstallable(arg1, "/some/path", arg2); argRecord.clear(); check.identifyEmbeddedPackage(arg1, arg2, arg3); Map.Entry<String, Object[]> call = argRecord.stream() .filter(entry -> "identifyEmbeddedPackage".equals(entry.getKey()) && entry.getValue().length == 4).findFirst() .orElse(null); assertNotNull("expect call for identifyEmbeddedPackage", call); assertSame("same arg1", arg1, call.getValue()[1]); assertSame("same arg2", arg2, call.getValue()[2]); assertSame("same arg3", arg3, call.getValue()[3]); }