run openrewrite

master
Markus Kreth 2 months ago
parent 3128f1fb46
commit 8e9671bec5
  1. 1
      Application_Properties.java
  2. 2
      pom.xml
  3. 1
      src/main/java/de/kreth/property2java/processor/GenerateProperty2Java.java
  4. 1
      src/main/java/de/kreth/property2java/processor/Property2JavaGenerator.java
  5. 3
      src/test/java/de/kreth/property2java/ConfigurationTest.java
  6. 7
      src/test/java/de/kreth/property2java/GeneratorTests.java
  7. 8
      src/test/java/de/kreth/property2java/processor/Property2JavaGeneratorTest.java

@ -146,7 +146,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<version>3.14.1</version>
<configuration>
<release>${java.version}</release>
<compilerArgs>-proc:none</compilerArgs>

@ -6,6 +6,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import de.kreth.property2java.Format;
import de.kreth.property2java.GeneratorOptions;

@ -16,6 +16,7 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic.Kind;
import de.kreth.property2java.Format;
import de.kreth.property2java.GeneratorException;
import de.kreth.property2java.GeneratorOptions;

@ -1,6 +1,7 @@
package de.kreth.property2java;
import static org.junit.jupiter.api.Assertions.*;
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;

@ -30,6 +30,7 @@ import java.util.Optional;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import org.apache.commons.cli.MissingOptionException;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
@ -200,19 +201,19 @@ class GeneratorTests {
doThrow(new TemplateException(null)).when(template).process(any(Map.class), any(Writer.class));
Generator generator = new Generator(config, template);
GeneratorException ex = assertThrows(GeneratorException.class, () -> generator.start());
GeneratorException ex = assertThrows(GeneratorException.class, generator::start);
assertThat(ex.getCause()).isInstanceOf(TemplateException.class);
}
@Test
void testMainMethod() throws IOException, GeneratorException {
Path source = Files.createTempFile(getClass().getSimpleName(), ".properties");
Generator.main(new String[] {"-t", "target", "-f", source.toString()});
Generator.main(new String[]{"-t", "target", "-f", source.toString()});
}
@Test
void testMainMethodMissingOption() throws IOException, GeneratorException {
IllegalStateException e = assertThrows(IllegalStateException.class, () -> Generator.main(new String[] {}));
IllegalStateException e = assertThrows(IllegalStateException.class, () -> Generator.main(new String[]{}));
assertThat(e.getCause()).isInstanceOf(MissingOptionException.class);
}

@ -42,12 +42,12 @@ public class Property2JavaGeneratorTest {
when(processingEnv.getMessager()).thenReturn(messanger);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
void testGeneratorInitializedCorrectly() {
GenerateProperty2Java an = mock(GenerateProperty2Java.class);
when(an.resources()).thenReturn(new String[] {});
when(an.resources()).thenReturn(new String[]{});
TypeElement element = mock(TypeElement.class);
when(element.getAnnotation(GenerateProperty2Java.class)).thenReturn(an);
@ -67,11 +67,11 @@ public class Property2JavaGeneratorTest {
return new GenerateResourceBundleProperty2Java[0];
}
};
when(annotatedElement.getAnnotation(GenerateResourceBundleProperty2Javas.class)).thenReturn(value );
when(annotatedElement.getAnnotation(GenerateResourceBundleProperty2Javas.class)).thenReturn(value);
Set<Element> elements = new HashSet<>(List.of(annotatedElement));
when(roundEnv.getElementsAnnotatedWith(GenerateResourceBundleProperty2Javas.class))
.thenReturn((Set)elements);
.thenReturn((Set) elements);
processor.process(annotations, roundEnv);

Loading…
Cancel
Save