You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
3 years ago
|
package lorem.ipsum.javatester;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.lang.reflect.InvocationTargetException;
|
||
|
import java.time.ZoneId;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
import org.chulk.codegen.CodeGenerator;
|
||
|
import org.junit.jupiter.api.Test;
|
||
|
|
||
|
import com.google.common.base.Charsets;
|
||
|
import com.google.common.io.Resources;
|
||
|
|
||
|
import lorem.ipsum.javatester.domain.CodeModel;
|
||
|
import lorem.ipsum.javatester.domain.Person;
|
||
|
|
||
|
public class CodeGenTest {
|
||
|
|
||
|
@Test
|
||
|
public void testCodeGenerator()
|
||
|
throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||
|
final CodeModel model = new CodeModel();
|
||
|
model.setName("Lorem Ipsum");
|
||
|
|
||
|
final CodeGenerator codeGen = CodeGenerator.create(Charsets.UTF_8);
|
||
|
codeGen.generateCode("lorem.ipsum.javatester.file.Generator",
|
||
|
codeGen.writeGeneratorCode(Resources.getResource("test-template.txt").getPath()), model);
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testGreetingGenerator()
|
||
|
throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||
|
Person mary = new Person("Mary", ZoneId.of("America/New_York"));
|
||
|
Person bob = new Person("Bob", ZoneId.of("Pacific/Auckland"));
|
||
|
|
||
|
List<Person> ppl = new ArrayList<>();
|
||
|
ppl.add(mary);
|
||
|
ppl.add(bob);
|
||
|
|
||
|
final CodeGenerator codeGen = CodeGenerator.create(Charsets.UTF_8);
|
||
|
codeGen.generateCode("lorem.ipsum.javatester.test.Generator",
|
||
|
codeGen.writeGeneratorCode(Resources.getResource("greeting-template.txt").getPath()), ppl);
|
||
|
}
|
||
|
|
||
|
}
|