openrewrite reformat

master
Markus Kreth 2 weeks ago
parent 94fe827d29
commit e117902e21
  1. 1
      Application_Properties.java
  2. 2
      pom.xml
  3. 3
      src/main/java/de/kreth/property2java/Generator.java
  4. 18
      src/test/java/de/kreth/property2java/GeneratorTests.java

@ -203,6 +203,8 @@
<configuration>
<activeRecipes>
<recipe>org.openrewrite.maven.BestPractices</recipe>
<recipe>org.openrewrite.java.OrderImports</recipe>
<recipe>org.openrewrite.java.format.AutoFormat</recipe>
</activeRecipes>
<exclusions>
<exclusion>**/generated/**</exclusion>

@ -91,8 +91,7 @@ public class Generator {
root.put("entries", entries);
@SuppressWarnings("unchecked")
List<String> propertyNames = Collections.list((Enumeration<String>) properties.propertyNames());
@SuppressWarnings("unchecked") List<String> propertyNames = Collections.list((Enumeration<String>) properties.propertyNames());
Collections.sort(propertyNames);
for (String propertyKeyString : propertyNames) {

@ -79,17 +79,14 @@ class GeneratorTests {
StringWriter out = new StringWriter();
when(config.outWriter(anyString())).thenReturn(out);
@SuppressWarnings("unchecked")
ArgumentCaptor<Map<String, Object>> rootCaptior = ArgumentCaptor.forClass(Map.class);
@SuppressWarnings("unchecked") ArgumentCaptor<Map<String, Object>> rootCaptior = ArgumentCaptor.forClass(Map.class);
generator.start();
verify(template).process(rootCaptior.capture(), any(Writer.class));
Map<String, Object> root = rootCaptior.getValue();
@SuppressWarnings("unchecked")
EnumSet<GeneratorOptions> options = (EnumSet<GeneratorOptions>) root.get("options");
@SuppressWarnings("unchecked") EnumSet<GeneratorOptions> options = (EnumSet<GeneratorOptions>) root.get("options");
assertThat(options).contains(GeneratorOptions.WithMessageFormatter, GeneratorOptions.WithSubstitutors);
@SuppressWarnings("unchecked")
List<String> imports = (List<String>) root.get("imports");
@SuppressWarnings("unchecked") List<String> imports = (List<String>) root.get("imports");
assertThat(imports).contains("java.text.MessageFormat");
}
@ -103,13 +100,11 @@ class GeneratorTests {
StringWriter out = new StringWriter();
when(config.outWriter(anyString())).thenReturn(out);
@SuppressWarnings("unchecked")
ArgumentCaptor<Map<String, Object>> rootCaptior = ArgumentCaptor.forClass(Map.class);
@SuppressWarnings("unchecked") ArgumentCaptor<Map<String, Object>> rootCaptior = ArgumentCaptor.forClass(Map.class);
generator.start();
verify(template).process(rootCaptior.capture(), any(Writer.class));
Map<String, Object> root = rootCaptior.getValue();
@SuppressWarnings("unchecked")
EnumSet<GeneratorOptions> options = (EnumSet<GeneratorOptions>) root.get("options");
@SuppressWarnings("unchecked") EnumSet<GeneratorOptions> options = (EnumSet<GeneratorOptions>) root.get("options");
assertThat(options).contains(GeneratorOptions.WithSubstitutors);
assertFalse(root.containsKey("imports"));
@ -215,8 +210,7 @@ class GeneratorTests {
String fileName = "de.kreth.messages.properties";
generator.generate(properties, out, fileName, config);
@SuppressWarnings("unchecked")
ArgumentCaptor<Map<String, Object>> dataModelCaptor = ArgumentCaptor.forClass(Map.class);
@SuppressWarnings("unchecked") ArgumentCaptor<Map<String, Object>> dataModelCaptor = ArgumentCaptor.forClass(Map.class);
verify(template).process(dataModelCaptor.capture(), any(Writer.class));
assertThat(dataModelCaptor.getValue())
.containsEntry("bundle_base_name", "de.kreth.messages")

Loading…
Cancel
Save