diff --git a/Application_Properties.java b/Application_Properties.java index 8b13789..e69de29 100644 --- a/Application_Properties.java +++ b/Application_Properties.java @@ -1 +0,0 @@ - diff --git a/pom.xml b/pom.xml index b00f0b8..b27af36 100644 --- a/pom.xml +++ b/pom.xml @@ -203,6 +203,8 @@ org.openrewrite.maven.BestPractices + org.openrewrite.java.OrderImports + org.openrewrite.java.format.AutoFormat **/generated/** diff --git a/src/main/java/de/kreth/property2java/Generator.java b/src/main/java/de/kreth/property2java/Generator.java index 20484bd..cb27cba 100644 --- a/src/main/java/de/kreth/property2java/Generator.java +++ b/src/main/java/de/kreth/property2java/Generator.java @@ -91,8 +91,7 @@ public class Generator { root.put("entries", entries); - @SuppressWarnings("unchecked") - List propertyNames = Collections.list((Enumeration) properties.propertyNames()); + @SuppressWarnings("unchecked") List propertyNames = Collections.list((Enumeration) properties.propertyNames()); Collections.sort(propertyNames); for (String propertyKeyString : propertyNames) { diff --git a/src/main/java/de/kreth/property2java/GeneratorOptions.java b/src/main/java/de/kreth/property2java/GeneratorOptions.java index 2fe4637..dfb2d4a 100644 --- a/src/main/java/de/kreth/property2java/GeneratorOptions.java +++ b/src/main/java/de/kreth/property2java/GeneratorOptions.java @@ -15,7 +15,7 @@ public enum GeneratorOptions { private final String[] additionalImport; GeneratorOptions(String... additionalImport) { - this.additionalImport = additionalImport!= null ? additionalImport : new String[]{}; + this.additionalImport = additionalImport != null ? additionalImport : new String[]{}; } String[] getAdditionalImport() { diff --git a/src/main/java/de/kreth/property2java/config/FreemarkerConfig.java b/src/main/java/de/kreth/property2java/config/FreemarkerConfig.java index ebef6c6..3993638 100644 --- a/src/main/java/de/kreth/property2java/config/FreemarkerConfig.java +++ b/src/main/java/de/kreth/property2java/config/FreemarkerConfig.java @@ -16,16 +16,16 @@ public enum FreemarkerConfig { public Template getTemplate(Format format) throws IOException { switch (format) { - case WithInitializer: - return cfg.getTemplate("enum_template_with_initializer.tpl"); - case WithInnerPropertyLoader: - return cfg.getTemplate("enum_template_with_inner_properties.tpl"); - case WithInnerPropertyResourceBundle: - return cfg.getTemplate("enum_template_with_inner_propertyresourcebundle.tpl"); - case WithUnaryOperatorParameter: - return cfg.getTemplate("enum_template.tpl"); - default: - throw new IllegalArgumentException("Format " + format + " is not supported."); + case WithInitializer: + return cfg.getTemplate("enum_template_with_initializer.tpl"); + case WithInnerPropertyLoader: + return cfg.getTemplate("enum_template_with_inner_properties.tpl"); + case WithInnerPropertyResourceBundle: + return cfg.getTemplate("enum_template_with_inner_propertyresourcebundle.tpl"); + case WithUnaryOperatorParameter: + return cfg.getTemplate("enum_template.tpl"); + default: + throw new IllegalArgumentException("Format " + format + " is not supported."); } } diff --git a/src/test/java/de/kreth/property2java/ConfigurationTest.java b/src/test/java/de/kreth/property2java/ConfigurationTest.java index 674bfd3..fcaa492 100644 --- a/src/test/java/de/kreth/property2java/ConfigurationTest.java +++ b/src/test/java/de/kreth/property2java/ConfigurationTest.java @@ -1,6 +1,6 @@ package de.kreth.property2java; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; @@ -31,7 +31,7 @@ class ConfigurationTest { when(config.outputCharset()).thenCallRealMethod(); Writer outWriter = config.outWriter("application.properties"); - assertInstanceOf(FileWriter.class, outWriter); + assertInstanceOf(FileWriter.class, outWriter); } @Test diff --git a/src/test/java/de/kreth/property2java/GeneratorTests.java b/src/test/java/de/kreth/property2java/GeneratorTests.java index 9975844..8c50440 100644 --- a/src/test/java/de/kreth/property2java/GeneratorTests.java +++ b/src/test/java/de/kreth/property2java/GeneratorTests.java @@ -79,17 +79,14 @@ class GeneratorTests { StringWriter out = new StringWriter(); when(config.outWriter(anyString())).thenReturn(out); - @SuppressWarnings("unchecked") - ArgumentCaptor> rootCaptior = ArgumentCaptor.forClass(Map.class); + @SuppressWarnings("unchecked") ArgumentCaptor> rootCaptior = ArgumentCaptor.forClass(Map.class); generator.start(); verify(template).process(rootCaptior.capture(), any(Writer.class)); Map root = rootCaptior.getValue(); - @SuppressWarnings("unchecked") - EnumSet options = (EnumSet) root.get("options"); + @SuppressWarnings("unchecked") EnumSet options = (EnumSet) root.get("options"); assertThat(options).contains(GeneratorOptions.WithMessageFormatter, GeneratorOptions.WithSubstitutors); - @SuppressWarnings("unchecked") - List imports = (List) root.get("imports"); + @SuppressWarnings("unchecked") List imports = (List) 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> rootCaptior = ArgumentCaptor.forClass(Map.class); + @SuppressWarnings("unchecked") ArgumentCaptor> rootCaptior = ArgumentCaptor.forClass(Map.class); generator.start(); verify(template).process(rootCaptior.capture(), any(Writer.class)); Map root = rootCaptior.getValue(); - @SuppressWarnings("unchecked") - EnumSet options = (EnumSet) root.get("options"); + @SuppressWarnings("unchecked") EnumSet options = (EnumSet) root.get("options"); assertThat(options).contains(GeneratorOptions.WithSubstitutors); assertFalse(root.containsKey("imports")); @@ -215,13 +210,12 @@ class GeneratorTests { String fileName = "de.kreth.messages.properties"; generator.generate(properties, out, fileName, config); - @SuppressWarnings("unchecked") - ArgumentCaptor> dataModelCaptor = ArgumentCaptor.forClass(Map.class); + @SuppressWarnings("unchecked") ArgumentCaptor> dataModelCaptor = ArgumentCaptor.forClass(Map.class); verify(template).process(dataModelCaptor.capture(), any(Writer.class)); assertThat(dataModelCaptor.getValue()) - .containsEntry("bundle_base_name", "de.kreth.messages") - .containsEntry("fileName", fileName) - .containsEntry("classname", "De_Kreth_Messages_Properties"); + .containsEntry("bundle_base_name", "de.kreth.messages") + .containsEntry("fileName", fileName) + .containsEntry("classname", "De_Kreth_Messages_Properties"); } @Test diff --git a/src/test/java/de/kreth/property2java/parts/ReplaceLogicForTemplateTest.java b/src/test/java/de/kreth/property2java/parts/ReplaceLogicForTemplateTest.java index 87dc9eb..69760ff 100644 --- a/src/test/java/de/kreth/property2java/parts/ReplaceLogicForTemplateTest.java +++ b/src/test/java/de/kreth/property2java/parts/ReplaceLogicForTemplateTest.java @@ -76,10 +76,10 @@ public class ReplaceLogicForTemplateTest { void testMissingReplacement() { String property = "Start{1}End"; assertThatThrownBy(() -> doReplacements(property, "|0|")) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("{1}") // Orignal Placeholder - .hasMessageContaining("Position=5") // Index of missing Placeholder - .hasMessageContaining(property); // Orignal Text + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("{1}") // Orignal Placeholder + .hasMessageContaining("Position=5") // Index of missing Placeholder + .hasMessageContaining(property); // Orignal Text } } diff --git a/src/test/java/de/kreth/property2java/processor/ProcessorConfigurationTest.java b/src/test/java/de/kreth/property2java/processor/ProcessorConfigurationTest.java index a9b77ed..6d1b648 100644 --- a/src/test/java/de/kreth/property2java/processor/ProcessorConfigurationTest.java +++ b/src/test/java/de/kreth/property2java/processor/ProcessorConfigurationTest.java @@ -46,9 +46,9 @@ public class ProcessorConfigurationTest { when(fileObject.openReader(false)).thenReturn(input); ProcessorConfiguration config = new ProcessorConfiguration( - ProcessorConfiguration.builder(filer, element) - .withFormat(Format.WithInnerPropertyLoader) - .addAll(resourceName)); + ProcessorConfiguration.builder(filer, element) + .withFormat(Format.WithInnerPropertyLoader) + .addAll(resourceName)); assertThat(config.getPackage()).isEqualTo(packageName); } diff --git a/src/test/java/de/kreth/property2java/processor/Property2JavaGeneratorTest.java b/src/test/java/de/kreth/property2java/processor/Property2JavaGeneratorTest.java index cb10126..bdbc23e 100644 --- a/src/test/java/de/kreth/property2java/processor/Property2JavaGeneratorTest.java +++ b/src/test/java/de/kreth/property2java/processor/Property2JavaGeneratorTest.java @@ -71,7 +71,7 @@ public class Property2JavaGeneratorTest { Set elements = new HashSet<>(List.of(annotatedElement)); when(roundEnv.getElementsAnnotatedWith(GenerateResourceBundleProperty2Javas.class)) - .thenReturn((Set) elements); + .thenReturn((Set) elements); processor.process(annotations, roundEnv);