Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014 Objectos, Fábrica de Software LTDA.
   *
   * 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 br.com.objectos.way.auto.pojo;
 
 
 
 

Author(s):
marcio.endo@objectos.com.br (Marcio Endo)
 
 public class AutoPojoProcessorTest {
 
   public void constructor() {
     autoPojo("Constructor");
   }
 
   public void generic() {
     autoPojo("Generic");
   }
 
   public void has_generic_return() {
     autoPojo("HasGenericReturn");
   }
 
   public void is_testable() {
     autoPojo("IsTestable");
   }
 
   public void simple() {
     autoPojo("Simple");
   }
 
   public void subclass() {
     ..about(JavaSourcesSubjectFactory.javaSources())
         .that(forResource("code/way-auto-pojo/Subclass.java""code/way-auto-pojo/IsTestable.java"))
         .processedWith(new AutoPojoProcessor())
         .compilesWithoutError()
         .and().generatesSources(
             forSourceCode("SubclassPojo""/code/way-auto-pojo/SubclassPojo.java"),
             forSourceCode("SubclassBuilder""/code/way-auto-pojo/SubclassBuilder.java"),
             forSourceCode("SubclassBuilderPojo""/code/way-auto-pojo/SubclassBuilderPojo.java"),
             forSourceCode("IsTestablePojo""/code/way-auto-pojo/IsTestablePojo.java"),
             forSourceCode("IsTestableBuilder""/code/way-auto-pojo/IsTestableBuilder.java"),
             forSourceCode("IsTestableBuilderPojo""/code/way-auto-pojo/IsTestableBuilderPojo.java"));
   }
 
   private void autoPojo(String name) {
     ..about(JavaSourcesSubjectFactory.javaSources())
     .that(forResource("code/way-auto-pojo/" + name + ".java"))
     .and().generatesSources(
         forSourceCode(name + "Pojo""/code/way-auto-pojo/" + name + "Pojo.java"),
         forSourceCode(name + "Builder""/code/way-auto-pojo/" + name + "Builder.java"),
         forSourceCode(name + "BuilderPojo""/code/way-auto-pojo/" + name + "BuilderPojo.java"));
   }
 
   private Iterable<? extends JavaFileObjectforResource(String... paths) {
     return WayIterables.from(paths)
         .toImmutableList();
   }
 
   private JavaFileObject forSourceCode(String nameString path) {
     String source = WayAsserts.contentsOf(path);
     String qname = "br.com.objectos.way.auto.core.fakes." + name;
     return JavaFileObjects.forSourceString(qnamesource);
   }
 
   private static enum PathToJavaFileObject implements Function<StringJavaFileObject> {
     INSTANCE;
     @Override
     public JavaFileObject apply(String input) {
       return JavaFileObjects.forResource(input);
     }
   }
New to GrepCode? Check out our FAQ X