CodeDeployUtil { @NotNull static Map<String, String> getRevisionPathMappings(@NotNull String revisionPathsParam) { final String readyRevision = getReadyRevision(revisionPathsParam); if (readyRevision == null) { final Map<String, String> dest = new LinkedHashMap<String, String>(); for (String path : revisionPathsParam.trim().split(MULTILINE_SPLIT_REGEX)) { final String[] parts = path.split(PATH_SPLIT_REGEX); if (parts.length > 0) { dest.put( normalize(parts[0], true), parts.length == 1 ? StringUtil.EMPTY : normalize(parts[1], false)); } } return Collections.unmodifiableMap(dest); } return Collections.<String, String>emptyMap(); }  @Contract("null, _ -> null") static String truncateStringValueWithDotsAtCenter(@Nullable final String str, final int maxLength); @NotNull static Collection<String> getAutoScalingGroups(@NotNull Map<String, String> params); @NotNull static Map<String, String> getEC2Tags(@NotNull Map<String, String> params); @Nullable static String getBundleType(@NotNull String revision); @Nullable static String getDeploymentSteps(@NotNull Map<String, String> params); @Nullable static String getRevisionPaths(@NotNull Map<String, String> params); @Nullable static String getS3BucketName(@NotNull Map<String, String> params); @Nullable static String getS3ObjectKey(@NotNull Map<String, String> params); @Nullable static String getFileExistsBehavior(@NotNull Map<String, String> params); @Nullable static String getAppName(@NotNull Map<String, String> params); @Nullable static String getDeploymentGroupName(@NotNull Map<String, String> params); @Nullable static String getDeploymentConfigName(@NotNull Map<String, String> params); @Nullable static String getWaitFlag(@NotNull Map<String, String> params); @Nullable static String getWaitTimeOutSec(@NotNull Map<String, String> params); @Nullable static String getRollbackOnFailure(@NotNull Map<String, String> params); @Nullable static String getRollbackOnAlarmThreshold(@NotNull Map<String, String> params); @Nullable static String getGreenFleet(@NotNull Map<String, String> params);  }
@Test public void revision_path_mappings() { then(getRevisionPathMappings("ready_revision/")).hasSize(1).containsEntry("ready_revision/", ""); then(getRevisionPathMappings("ready_revision\\")).hasSize(1).containsEntry("ready_revision/", ""); then(getRevisionPathMappings("ready_revision.zip")).isEmpty(); then(getRevisionPathMappings("ready_revision.tar")).isEmpty(); then(getRevisionPathMappings("ready_revision.tar.gz")).isEmpty(); then(getRevisionPathMappings("ready_revision.jar")).hasSize(1).containsEntry("ready_revision.jar", ""); then(getRevisionPathMappings("**/ready_revision.zip")).hasSize(1).containsEntry("**/ready_revision.zip", ""); then(getRevisionPathMappings("*.zip")).hasSize(1).containsEntry("*.zip", ""); then(getRevisionPathMappings("abc?.zip")).hasSize(1).containsEntry("abc?.zip", ""); then(getRevisionPathMappings("ready_revision.tar\nready_revision.zip")).hasSize(2).containsEntry("ready_revision.tar", "").containsEntry("ready_revision.zip", ""); then(getRevisionPathMappings("ready_revision.tar,ready_revision.zip")).hasSize(2).containsEntry("ready_revision.tar", "").containsEntry("ready_revision.zip", ""); then(getRevisionPathMappings("ready_revision.zip=>")).hasSize(1).containsEntry("ready_revision.zip", ""); then(getRevisionPathMappings("ready_revision.zip=>.")).hasSize(1).containsEntry("ready_revision.zip", ""); then(getRevisionPathMappings("foo\\bar\\baz\\*.html=>x\\y\\z")).hasSize(1).containsEntry("foo/bar/baz/*.html", "x/y/z"); then(getRevisionPathMappings("foo/bar/baz/=>x/y/z/")).hasSize(1).containsEntry("foo/bar/baz/", "x/y/z"); then(getRevisionPathMappings("foo\\bar\\baz\\=>x\\y\\z\\")).hasSize(1).containsEntry("foo/bar/baz/", "x/y/z"); then(getRevisionPathMappings("./foo/bar/baz/../../bar/baz/=>./x/y/z/../../y/z/")).hasSize(1).containsEntry("foo/bar/baz/", "x/y/z"); then(getRevisionPathMappings("")).hasSize(1).containsEntry("**", ""); then(getRevisionPathMappings(".")).hasSize(1).containsEntry("**", ""); then(getRevisionPathMappings("=>.")).hasSize(1).containsEntry("**", ""); then(getRevisionPathMappings(".=>")).hasSize(1).containsEntry("**", ""); then(getRevisionPathMappings(".=>.")).hasSize(1).containsEntry("**", ""); }