content: /*
   * Copyright 2021-2022 Alibaba Group Holding Ltd.
   *
   *    Licensed under the Apache License, Version 2.0 (the "License");
   *    you may not use this file except in compliance with the License.
   *    You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *    Unless required by applicable law or agreed to in writing, software
   *    distributed under the License is distributed on an "AS IS" BASIS,
   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *    See the License for the specific language governing permissions and
   *    limitations under the License.
   */
  
  package com.aliyun.fastmodel.parser.processor;
  
  import java.io.IOException;
  
  import javax.lang.model.element.Modifier;
  
  import com.squareup.javapoet.JavaFile;
  import com.squareup.javapoet.MethodSpec;
  import com.squareup.javapoet.TypeSpec;
  import org.junit.Test;
  
  /**
   * Desc:
   *
   * @author panguanjing
   * @date 2021/4/6
   */
  public class GeneratorSourceTest {
      @Test
      public void testGenerator() throws IOException {
          MethodSpec main = MethodSpec.methodBuilder("main")
              .addModifiers(Modifier.PUBLIC, Modifier.STATIC)
              .returns(void.class)
              .addParameter(String[].class, "args")
              .addStatement("$T.out.println($S)", System.class, "Hello, JavaPoet!")
              .build();
  
          TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
              .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
              .addMethod(main)
              .build();
  
          JavaFile javaFile = JavaFile.builder("com.example.helloworld", helloWorld)
              .build();
  
          javaFile.writeTo(System.out);
      }
  
  }
  