Search in sources :

Example 41 with TypeDef

use of io.sundr.model.TypeDef in project sundrio by sundrio.

the class SimpleClassWithInheritanceTest method testEditable.

@Test
public void testEditable() {
    TypeDef editable = ClazzAs.EDITABLE.apply(simpleClassWithDateDef);
    System.out.println(editable);
    assertEquals(Kind.CLASS, editable.getKind());
    assertEquals("EditableSimpleClassWithDate", editable.getName());
    assertEquals(1, editable.getExtendsList().size());
    ClassRef superClass = editable.getExtendsList().iterator().next();
    assertEquals(simpleClassWithDateDef.toInternalReference(), superClass);
}
Also used : TypeDef(io.sundr.model.TypeDef) RichTypeDef(io.sundr.model.RichTypeDef) ClassRef(io.sundr.model.ClassRef) Test(org.junit.Test)

Example 42 with TypeDef

use of io.sundr.model.TypeDef in project sundrio by sundrio.

the class SimpleClassWithInheritanceTest method testInline.

@Test
public void testInline() {
    TypeDef inlineable = BuildableProcessor.inlineableOf(builderContext, simpleClassWithDateDef, inline);
    System.out.println(inlineable);
    assertEquals(Kind.CLASS, inlineable.getKind());
    assertEquals("CallableSimpleClassWithDate", inlineable.getName());
}
Also used : TypeDef(io.sundr.model.TypeDef) RichTypeDef(io.sundr.model.RichTypeDef) Test(org.junit.Test)

Example 43 with TypeDef

use of io.sundr.model.TypeDef in project sundrio by sundrio.

the class SimpleClassWithParameterTest method testEditable.

@Test
public void testEditable() {
    TypeDef editable = ClazzAs.EDITABLE.apply(simpleClassWithParameterDef);
    System.out.println(editable);
    assertEquals(Kind.CLASS, editable.getKind());
    assertEquals("EditableSimpleClassWithParameter", editable.getName());
    assertEquals(1, editable.getExtendsList().size());
    ClassRef superClass = editable.getExtendsList().iterator().next();
    assertEquals(simpleClassWithParameterDef.toInternalReference(), superClass);
}
Also used : TypeDef(io.sundr.model.TypeDef) RichTypeDef(io.sundr.model.RichTypeDef) ClassRef(io.sundr.model.ClassRef) Test(org.junit.Test)

Example 44 with TypeDef

use of io.sundr.model.TypeDef in project sundrio by sundrio.

the class SimpleClassWithParameterTest method testFluentImpl.

@Test
public void testFluentImpl() {
    TypeDef fluentImpl = ClazzAs.FLUENT_IMPL.apply(simpleClassWithParameterDef);
    System.out.println(fluentImpl);
    assertEquals(Kind.CLASS, fluentImpl.getKind());
    assertEquals("SimpleClassWithParameterFluentImpl", fluentImpl.getName());
    assertEquals(1, fluentImpl.getExtendsList().size());
    ClassRef superClass = fluentImpl.getExtendsList().iterator().next();
    assertEquals("BaseFluent", superClass.getName());
    assertEquals(1, superClass.getArguments().size());
    assertEquals("A", superClass.getArguments().iterator().next().toString());
}
Also used : TypeDef(io.sundr.model.TypeDef) RichTypeDef(io.sundr.model.RichTypeDef) ClassRef(io.sundr.model.ClassRef) Test(org.junit.Test)

Example 45 with TypeDef

use of io.sundr.model.TypeDef in project sundrio by sundrio.

the class BuilderGeneratorTest method testFluentTemplate.

@Test
public void testFluentTemplate() throws IOException {
    TypeDef type = new TypeDefBuilder().withName("Circle").withPackageName("my.Test").addNewConstructor().addNewArgument().withName("w").withTypeRef(Types.INT_REF).endArgument().addNewArgument().withName("w").withTypeRef(Types.INT_REF).endArgument().endConstructor().build();
    File tmp = new File(System.getProperty("java.io.tmpdir"));
    generate(type, tmp, "CircleFluent.java", Constants.DEFAULT_SOURCEFILE_TEMPLATE_LOCATION);
    generate(type, tmp, "CircleBuilder.java", Constants.DEFAULT_SOURCEFILE_TEMPLATE_LOCATION);
}
Also used : TypeDef(io.sundr.model.TypeDef) TypeDefBuilder(io.sundr.model.TypeDefBuilder) File(java.io.File) Test(org.junit.Test)

Aggregations

TypeDef (io.sundr.model.TypeDef)99 ClassRef (io.sundr.model.ClassRef)43 Test (org.junit.Test)40 RichTypeDef (io.sundr.model.RichTypeDef)38 TypeDefBuilder (io.sundr.model.TypeDefBuilder)35 TypeRef (io.sundr.model.TypeRef)26 Method (io.sundr.model.Method)22 Property (io.sundr.model.Property)22 ArrayList (java.util.ArrayList)20 List (java.util.List)15 TypeElement (javax.lang.model.element.TypeElement)15 Collectors (java.util.stream.Collectors)14 Element (javax.lang.model.element.Element)14 Set (java.util.Set)12 Test (org.junit.jupiter.api.Test)12 AnnotationRef (io.sundr.model.AnnotationRef)11 DefinitionRepository (io.sundr.model.repo.DefinitionRepository)11 HashMap (java.util.HashMap)11 AptContext (io.sundr.adapter.apt.AptContext)10 ClassRefBuilder (io.sundr.model.ClassRefBuilder)10