Search in sources :

Example 71 with TypeDef

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

the class SimpleClassWithInheritanceTest method testBuilder.

@Test
public void testBuilder() throws FileNotFoundException {
    TypeDef builder = ClazzAs.BUILDER.apply(simpleClassWithDateDef);
    System.out.println(builder);
    assertEquals(Kind.CLASS, builder.getKind());
    assertEquals("SimpleClassWithDateBuilder", builder.getName());
    assertEquals(1, builder.getExtendsList().size());
    ClassRef superClass = builder.getImplementsList().iterator().next();
    assertEquals(builderContext.getVisitableBuilderInterface().getName(), superClass.getName());
    assertEquals(2, superClass.getArguments().size());
    Iterator<TypeRef> argIterator = superClass.getArguments().iterator();
    TypeRef ref = argIterator.next();
    assertEquals("testpackage.SimpleClassWithDate", ref.render());
    assertEquals("testpackage.SimpleClassWithDate", ref.toString());
    ref = argIterator.next();
    assertEquals("testpackage.SimpleClassWithDateBuilder", ref.render());
    assertEquals("testpackage.SimpleClassWithDateBuilder", ref.toString());
}
Also used : TypeDef(io.sundr.model.TypeDef) RichTypeDef(io.sundr.model.RichTypeDef) ClassRef(io.sundr.model.ClassRef) TypeRef(io.sundr.model.TypeRef) Test(org.junit.Test)

Example 72 with TypeDef

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

the class SimpleClassWithInheritanceTest method testFluentImpl.

@Test
public void testFluentImpl() throws FileNotFoundException {
    TypeDef fluentImpl = ClazzAs.FLUENT_IMPL.apply(simpleClassWithDateDef);
    System.out.println(fluentImpl);
    assertEquals(Kind.CLASS, fluentImpl.getKind());
    assertEquals("SimpleClassWithDateFluentImpl", fluentImpl.getName());
    assertEquals(1, fluentImpl.getExtendsList().size());
    ClassRef superClass = fluentImpl.getExtendsList().iterator().next();
    assertEquals("SimpleClassFluentImpl", 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 73 with TypeDef

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

the class SimpleClassWithParameterTest method testBuilder.

@Test
public void testBuilder() {
    TypeDef builder = ClazzAs.BUILDER.apply(simpleClassWithParameterDef);
    System.out.println(builder);
    assertEquals(Kind.CLASS, builder.getKind());
    assertEquals("SimpleClassWithParameterBuilder", builder.getName());
    assertEquals(1, builder.getExtendsList().size());
    ClassRef superClass = builder.getImplementsList().iterator().next();
    assertEquals("VisitableBuilder", superClass.getName());
    assertEquals(2, superClass.getArguments().size());
    Iterator<TypeRef> argIterator = superClass.getArguments().iterator();
    TypeRef ref = argIterator.next();
    assertEquals("testpackage.SimpleClassWithParameter<N>", ref.render());
    assertEquals("testpackage.SimpleClassWithParameter<N>", ref.toString());
    ref = argIterator.next();
    assertEquals("testpackage.SimpleClassWithParameterBuilder<N>", ref.render());
    assertEquals("testpackage.SimpleClassWithParameterBuilder<N>", ref.toString());
}
Also used : TypeDef(io.sundr.model.TypeDef) RichTypeDef(io.sundr.model.RichTypeDef) ClassRef(io.sundr.model.ClassRef) TypeRef(io.sundr.model.TypeRef) Test(org.junit.Test)

Example 74 with TypeDef

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

the class SimpleClassWithParameterTest method testFluent.

@Test
public void testFluent() {
    TypeDef fluent = ClazzAs.FLUENT_INTERFACE.apply(simpleClassWithParameterDef);
    System.out.println(fluent);
    assertEquals(Kind.INTERFACE, fluent.getKind());
    assertEquals("SimpleClassWithParameterFluent", fluent.getName());
    assertEquals(1, fluent.getExtendsList().size());
    ClassRef superClass = fluent.getExtendsList().iterator().next();
    assertEquals("Fluent", 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 75 with TypeDef

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

the class SimpleClassWithParameterTest method testInline.

@Test
public void testInline() {
    TypeDef inlineable = BuildableProcessor.inlineableOf(builderContext, simpleClassWithParameterDef, inline);
    System.out.println(inlineable);
    assertEquals(Kind.CLASS, inlineable.getKind());
    assertEquals("CallableSimpleClassWithParameter", inlineable.getName());
}
Also used : TypeDef(io.sundr.model.TypeDef) RichTypeDef(io.sundr.model.RichTypeDef) 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