Search in sources :

Example 6 with TypeDef

use of io.sundr.model.TypeDef in project kubernetes-client by fabric8io.

the class SpecReplicasPathDetectorTest method shoudDetectSpecReplicasPath.

@Test
public void shoudDetectSpecReplicasPath() throws Exception {
    TypeDef def = Adapters.adaptType(WebServerWithStatusProperty.class, CONTEXT);
    SpecReplicasPathDetector detector = new SpecReplicasPathDetector();
    def = new TypeDefBuilder(def).accept(detector).build();
    assertTrue(detector.getPath().isPresent());
    assertEquals(".replicas", detector.getPath().get());
}
Also used : TypeDef(io.sundr.model.TypeDef) TypeDefBuilder(io.sundr.model.TypeDefBuilder) Test(org.junit.jupiter.api.Test)

Example 7 with TypeDef

use of io.sundr.model.TypeDef in project kubernetes-client by fabric8io.

the class SpecReplicasPathDetectorTest method shoudDetectNestedSpecReplicasPath.

@Test
public void shoudDetectNestedSpecReplicasPath() throws Exception {
    TypeDef def = Adapters.adaptType(WebServerWithSpec.class, CONTEXT);
    SpecReplicasPathDetector detector = new SpecReplicasPathDetector();
    def = new TypeDefBuilder(def).accept(detector).build();
    assertTrue(detector.getPath().isPresent());
    assertEquals(".spec.replicas", detector.getPath().get());
}
Also used : TypeDef(io.sundr.model.TypeDef) TypeDefBuilder(io.sundr.model.TypeDefBuilder) Test(org.junit.jupiter.api.Test)

Example 8 with TypeDef

use of io.sundr.model.TypeDef in project kubernetes-client by fabric8io.

the class TypesTest method shouldHaveAllTheExpectedProperties.

@Test
void shouldHaveAllTheExpectedProperties() {
    final TypeDef def = Types.typeDefFrom(Joke.class);
    final List<Property> properties = def.getProperties();
    assertEquals(7, properties.size());
}
Also used : TypeDef(io.sundr.model.TypeDef) Property(io.sundr.model.Property) WebServerWithStatusProperty(io.fabric8.crd.example.webserver.WebServerWithStatusProperty) Test(org.junit.jupiter.api.Test)

Example 9 with TypeDef

use of io.sundr.model.TypeDef in project kubernetes-client by fabric8io.

the class TypesTest method shouldFindStatusProperty.

@Test
void shouldFindStatusProperty() {
    TypeDef def = Types.typeDefFrom(WebServerWithStatusProperty.class);
    Optional<Property> p = Types.findStatusProperty(def);
    assertTrue(p.isPresent());
    def = Types.typeDefFrom(Basic.class);
    p = Types.findStatusProperty(def);
    assertTrue(p.isPresent());
}
Also used : Basic(io.fabric8.crd.example.basic.Basic) TypeDef(io.sundr.model.TypeDef) Property(io.sundr.model.Property) WebServerWithStatusProperty(io.fabric8.crd.example.webserver.WebServerWithStatusProperty) Test(org.junit.jupiter.api.Test)

Example 10 with TypeDef

use of io.sundr.model.TypeDef in project kubernetes-client by fabric8io.

the class TypesTest method shouldFindInheritedStatusProperty.

@Test
void shouldFindInheritedStatusProperty() {
    final TypeDef def = Types.typeDefFrom(Child.class);
    final Optional<Property> p = Types.findStatusProperty(def);
    assertTrue(p.isPresent());
    final Property property = p.get();
    final TypeRef typeRef = property.getTypeRef();
    assertTrue(typeRef instanceof ClassRef);
    final ClassRef classRef = (ClassRef) typeRef;
    final SpecAndStatus specAndStatus = Types.resolveSpecAndStatusTypes(def);
    assertEquals(specAndStatus.getStatusClassName(), classRef.getFullyQualifiedName());
}
Also used : TypeDef(io.sundr.model.TypeDef) ClassRef(io.sundr.model.ClassRef) TypeRef(io.sundr.model.TypeRef) SpecAndStatus(io.fabric8.crd.generator.utils.Types.SpecAndStatus) Property(io.sundr.model.Property) WebServerWithStatusProperty(io.fabric8.crd.example.webserver.WebServerWithStatusProperty) Test(org.junit.jupiter.api.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