|
|
|
@ -6,7 +6,6 @@ import static org.mockito.Mockito.when; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.StringReader; |
|
|
|
import java.io.StringReader; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.processing.Filer; |
|
|
|
import javax.annotation.processing.Filer; |
|
|
|
import javax.lang.model.element.Name; |
|
|
|
import javax.lang.model.element.Name; |
|
|
|
import javax.lang.model.element.PackageElement; |
|
|
|
import javax.lang.model.element.PackageElement; |
|
|
|
@ -14,13 +13,13 @@ import javax.lang.model.element.TypeElement; |
|
|
|
import javax.tools.FileObject; |
|
|
|
import javax.tools.FileObject; |
|
|
|
import javax.tools.StandardLocation; |
|
|
|
import javax.tools.StandardLocation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import de.kreth.property2java.Format; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.extension.ExtendWith; |
|
|
|
import org.junit.jupiter.api.extension.ExtendWith; |
|
|
|
import org.mockito.Mock; |
|
|
|
import org.mockito.Mock; |
|
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
|
|
|
|
|
|
|
|
|
import de.kreth.property2java.Format; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class) |
|
|
|
@ExtendWith(MockitoExtension.class) |
|
|
|
public class ProcessorConfigurationTest { |
|
|
|
public class ProcessorConfigurationTest { |
|
|
|
|
|
|
|
|
|
|
|
@ -36,20 +35,21 @@ public class ProcessorConfigurationTest { |
|
|
|
String packageName = "de.kreth.pack.name"; |
|
|
|
String packageName = "de.kreth.pack.name"; |
|
|
|
String resourceName = "localization.properties"; |
|
|
|
String resourceName = "localization.properties"; |
|
|
|
FileObject fileObject = mock(FileObject.class); |
|
|
|
FileObject fileObject = mock(FileObject.class); |
|
|
|
StringReader input = new StringReader("key1=value1\n" |
|
|
|
StringReader input = new StringReader(""" |
|
|
|
+ "key2=value2"); |
|
|
|
key1=value1 |
|
|
|
|
|
|
|
key2=value2"""); |
|
|
|
|
|
|
|
|
|
|
|
when(element.getEnclosingElement()).thenReturn(packageElement); |
|
|
|
when(element.getEnclosingElement()).thenReturn(packageElement); |
|
|
|
when(packageElement.getQualifiedName()).thenReturn(name); |
|
|
|
when(packageElement.getQualifiedName()).thenReturn(name); |
|
|
|
when(name.toString()).thenReturn(packageName); |
|
|
|
when(name.toString()).thenReturn(packageName); |
|
|
|
when(filer.getResource(StandardLocation.CLASS_PATH, "", resourceName)).thenReturn(fileObject); |
|
|
|
when(filer.getResource(StandardLocation.CLASS_PATH, "", resourceName)).thenReturn(fileObject); |
|
|
|
when(fileObject.openReader(false)).thenReturn(input); |
|
|
|
when(fileObject.openReader(false)).thenReturn(input); |
|
|
|
|
|
|
|
|
|
|
|
ProcessorConfiguration config = new ProcessorConfiguration( |
|
|
|
ProcessorConfiguration config = new ProcessorConfiguration( |
|
|
|
ProcessorConfiguration.builder(filer, element) |
|
|
|
ProcessorConfiguration.builder(filer, element) |
|
|
|
.withFormat(Format.WithInnerPropertyLoader) |
|
|
|
.withFormat(Format.WithInnerPropertyLoader) |
|
|
|
.addAll(resourceName)); |
|
|
|
.addAll(resourceName)); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(config.getPackage()).isEqualTo(packageName); |
|
|
|
assertThat(config.getPackage()).isEqualTo(packageName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|