Skip to content

Commit

Permalink
Deserialize AddRuntimeConfig.Separator notation
Browse files Browse the repository at this point in the history
Fixes #4368
  • Loading branch information
timtebeek committed Aug 1, 2024
1 parent 0ed38dc commit 65fb0cf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.openrewrite.maven;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import org.openrewrite.*;
import org.openrewrite.internal.StringUtils;
Expand Down Expand Up @@ -65,8 +66,11 @@ public class AddRuntimeConfig extends ScanningRecipe<AddRuntimeConfig.Accumulato

@Getter
public enum Separator {
@JsonProperty("")
NONE(""),
@JsonProperty(" ")
SPACE(" "),
@JsonProperty("=")
EQUALS("=");

private final String notation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.openrewrite.DocumentExample;
import org.openrewrite.Issue;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.SourceSpecs;

Expand Down Expand Up @@ -52,6 +53,32 @@ void createConfigFileWithRuntimeConfigIfFileDoesNotExist() {
);
}

@Test
@Issue("https://github.com/openrewrite/rewrite/issues/4368")
void fromYaml() {
rewriteRun(
spec -> spec.recipeFromYaml(
"""
type: specs.openrewrite.org/v1beta/recipe
name: org.test.AddRuntimeConfig
description: Test deserialization.
recipeList:
- org.openrewrite.maven.AddRuntimeConfig:
relativeConfigFileName: maven.config
flag: -T
argument: 3
separator: '='
""", "org.test.AddRuntimeConfig"
),
POM_XML_SOURCE_SPEC,
text(
null,
"-T=3",
spec -> spec.path(MAVEN_CONFIG_PATH)
)
);
}

@Test
void appendRuntimeFlagToEmptyConfigFile() {
rewriteRun(
Expand Down

0 comments on commit 65fb0cf

Please sign in to comment.