ImageWorkflowOperationHandler extends AbstractWorkflowOperationHandler { static Fx<String> validateTargetBaseNameFormat(final String formatName) { return new Fx<String>() { @Override public void apply(String format) { boolean valid; try { final String name = formatFileName(format, 15.11, ".png"); valid = name.contains(".") && name.contains(".png"); } catch (IllegalFormatException e) { valid = false; } if (!valid) { chuck(new WorkflowOperationException(format( "%s is not a valid format string for config option %s", format, formatName))); } } }; }  void setWorkspace(Workspace workspace); @Override WorkflowOperationResult start(final WorkflowInstance wi, JobContext ctx); static StreamFold<MediaPackageElementFlavor, S> flavorFold(S selector); static StreamFold<String, S> tagFold(S selector); static Fn<String, EncodingProfile> fetchProfile(final ComposerService composerService); static final String OPT_SOURCE_FLAVOR; static final String OPT_SOURCE_FLAVORS; static final String OPT_SOURCE_TAGS; static final String OPT_PROFILES; static final String OPT_POSITIONS; static final String OPT_TARGET_FLAVOR; static final String OPT_TARGET_TAGS; static final String OPT_TARGET_BASE_NAME_FORMAT_SECOND; static final String OPT_TARGET_BASE_NAME_FORMAT_PERCENT; static final String OPT_END_MARGIN; static final double SINGLE_FRAME_POS; }
@Test public void testValidateTargetBaseNameFormat() { validateTargetBaseNameFormat("format-a").apply("thumbnail_%.1fs%s"); validateTargetBaseNameFormat("format-a").apply("thumbnail_%1$.1fs%2$s"); validateTargetBaseNameFormat("format-a").apply("%2$s_thumbnail_%1$.1fs%1$.1fs%2$s"); try { validateTargetBaseNameFormat("format-a").apply("thumbnail_%.1fs%.3f"); fail("Invalid format passed check. Suffix format %s is missing."); } catch (Exception ignore) { } try { validateTargetBaseNameFormat("format-a").apply("thumbnail_%.3f"); fail("Invalid format passed check. Suffix format %s is missing."); } catch (Exception ignore) { } try { validateTargetBaseNameFormat("format-a").apply("thumbnail_%s"); fail("Invalid format passed check. Suffix is missing since %s does not have a positional parameter."); } catch (Exception ignore) { } validateTargetBaseNameFormat("format-a").apply("thumbnail_%2$s"); }