Formatierung

pull/11/head
Markus Kreth 1 year ago
parent 5ad43ca39f
commit 216c3922fa
  1. 54
      src/test/java/de/kreth/property2java/GeneratorTests.java
  2. 3
      src/test/java/de/kreth/property2java/processor/Property2JavaGeneratorTest.java

@ -119,23 +119,19 @@ class GeneratorTests {
when(config.outWriter(anyString())).thenReturn(out); when(config.outWriter(anyString())).thenReturn(out);
generator.start(); generator.start();
List<String> lines = out.toString().lines().filter(line -> line.contains(" (\"")) List<String> lines = out.toString().lines().filter(line -> line.contains(" (\"")).collect(Collectors.toList());
.collect(Collectors.toList());
assertEquals(21, lines.size()); assertEquals(21, lines.size());
assertLineMatch(lines, "label", "label"); assertLineMatch(lines, "label", "label");
assertLineMatch(lines, "label_addarticle", "label.addarticle"); assertLineMatch(lines, "label_addarticle", "label.addarticle");
assertLineMatch(lines, "label_user_register", "label.user.register"); assertLineMatch(lines, "label_user_register", "label.user.register");
assertLineMatch(lines, "message_article_priceerror", "message.article.priceerror"); assertLineMatch(lines, "message_article_priceerror", "message.article.priceerror");
assertLineMatch(lines, "message_invoiceitem_startbeforeend", assertLineMatch(lines, "message_invoiceitem_startbeforeend", "message.invoiceitem.startbeforeend");
"message.invoiceitem.startbeforeend"); assertLineMatch(lines, "message_invoiceitem_allfieldsmustbeset", "message.invoiceitem.allfieldsmustbeset");
assertLineMatch(lines, "message_invoiceitem_allfieldsmustbeset",
"message.invoiceitem.allfieldsmustbeset");
} }
private void assertLineMatch(List<String> lines, String key, String expected) { private void assertLineMatch(List<String> lines, String key, String expected) {
Optional<String> found = lines.stream().filter(line -> keyMatches(line, key)) Optional<String> found = lines.stream().filter(line -> keyMatches(line, key)).findFirst();
.findFirst();
assertTrue(found.isPresent(), "No line found with key = " + key); assertTrue(found.isPresent(), "No line found with key = " + key);
final String line = found.get().trim(); final String line = found.get().trim();
@ -153,31 +149,21 @@ class GeneratorTests {
} }
private StringReader testProperties() { private StringReader testProperties() {
return new StringReader("\r\n" + return new StringReader("\r\n" + "label = \r\n" + "\r\n" + "label.addarticle = Add Article\r\n"
"label = \r\n" + + "label.cancel = Cancel\r\n" + "label.close = Close\r\n"
"\r\n" + + "label.delete = Delete\r\n" + "label.discart = Discart\r\n"
"label.addarticle = Add Article\r\n" + + "label.loggedin = Logged in:\r\n" + "label.logout = Logout\r\n"
"label.cancel = Cancel\r\n" + + "label.ok = OK\r\n" + "label.store = Store\r\n"
"label.close = Close\r\n" + + "label.preview = Preview\r\n" + "label.open = Open\r\n"
"label.delete = Delete\r\n" + + "label.user.register = Register\r\n" + "\r\n"
"label.discart = Discart\r\n" + + "message.article.priceerror = Please set the price.\r\n"
"label.loggedin = Logged in:\r\n" + + "message.delete.text = Delete {0}?\r\n"
"label.logout = Logout\r\n" + + "message.delete.title = Really delete?\r\n"
"label.ok = OK\r\n" + + "message.invoiceitem.allfieldsmustbeset = Start, end and article must not be \\r\\n"
"label.store = Store\r\n" + + " empty!\r\n"
"label.preview = Preview\r\n" + + "message.invoiceitem.startbeforeend = End must be later than start.\r\n"
"label.open = Open\r\n" + + "message.user.create.success = Thanks {0} created!\r\n"
"label.user.register = Register\r\n" + + "message.user.loginfailure = Login Error! Wrong user or password?\r\n"
"\r\n" + + "message.user.passwordmissmatch = Passwords don't match.\r\n" + "");
"message.article.priceerror = Please set the price.\r\n" +
"message.delete.text = Delete {0}?\r\n" +
"message.delete.title = Really delete?\r\n" +
"message.invoiceitem.allfieldsmustbeset = Start, end and article must not be \\r\\n" +
" empty!\r\n" +
"message.invoiceitem.startbeforeend = End must be later than start.\r\n" +
"message.user.create.success = Thanks {0} created!\r\n" +
"message.user.loginfailure = Login Error! Wrong user or password?\r\n" +
"message.user.passwordmissmatch = Passwords don't match.\r\n" +
"");
} }
} }

@ -39,8 +39,7 @@ public class Property2JavaGeneratorTest {
@Test @Test
void testGeneratorInitializedCorrectly() { void testGeneratorInitializedCorrectly() {
when(roundEnv.getElementsAnnotatedWith(ArgumentMatchers.any(Class.class))) when(roundEnv.getElementsAnnotatedWith(ArgumentMatchers.any(Class.class))).thenReturn(annotations);
.thenReturn(annotations);
processor.process(annotations, roundEnv); processor.process(annotations, roundEnv);
} }
} }

Loading…
Cancel
Save