Search in sources :

Example 1 with StringList

use of io.sundr.adapter.testing.list.StringList in project sundrio by sundrio.

the class AbstractAdapterTest method testWithTypeParams.

// 
// List
// 
@Test
public void testWithTypeParams() throws Exception {
    java.lang.reflect.Method method = ArrayList.class.getDeclaredMethod("get", int.class);
    T input = getInput(StringList.class);
    TypeDef typeDef = Adapters.adaptType(input, getContext());
    RichTypeDef stringList = TypeArguments.apply(typeDef);
    // methods
    assertFalse(stringList.getMethods().stream().anyMatch(m -> m.getName().equals("get")));
    assertTrue(stringList.getAllMethods().stream().anyMatch(m -> m.getName().equals("get") && m.getReturnType().equals(Types.STRING_REF)));
    // properties
    assertFalse(stringList.getProperties().stream().anyMatch(m -> m.getName().equals("elementData")));
    assertTrue(stringList.getAllProperties().stream().anyMatch(m -> m.getName().equals("elementData")));
}
Also used : ClassWithSelfRefParam(io.sundr.adapter.testing.general.ClassWithSelfRefParam) Person(io.sundr.adapter.testing.person.Person) GetDefinition(io.sundr.model.functions.GetDefinition) StringList(io.sundr.adapter.testing.list.StringList) ClassWithPrimitiveArray(io.sundr.adapter.testing.general.ClassWithPrimitiveArray) AdapterContext(io.sundr.adapter.api.AdapterContext) ArrayList(java.util.ArrayList) ClassRef(io.sundr.model.ClassRef) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) Address(io.sundr.adapter.testing.person.Address) SimpleClass(io.sundr.adapter.testing.general.SimpleClass) RichTypeDef(io.sundr.model.RichTypeDef) Types(io.sundr.model.utils.Types) ClassWithAnnotation(io.sundr.adapter.testing.general.ClassWithAnnotation) Assert.assertNotNull(org.junit.Assert.assertNotNull) ClassWithSuperClassParam(io.sundr.adapter.testing.general.ClassWithSuperClassParam) Adapters(io.sundr.adapter.api.Adapters) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) Test(org.junit.Test) Method(io.sundr.model.Method) TypeRef(io.sundr.model.TypeRef) AnnotationRef(io.sundr.model.AnnotationRef) Collectors(java.util.stream.Collectors) Property(io.sundr.model.Property) List(java.util.List) ClassWithArray(io.sundr.adapter.testing.general.ClassWithArray) PrimitiveRef(io.sundr.model.PrimitiveRef) TypeArguments(io.sundr.model.utils.TypeArguments) Assert.assertFalse(org.junit.Assert.assertFalse) TypeDef(io.sundr.model.TypeDef) Optional(java.util.Optional) ClassWithParam(io.sundr.adapter.testing.general.ClassWithParam) Assert.assertEquals(org.junit.Assert.assertEquals) RichTypeDef(io.sundr.model.RichTypeDef) TypeDef(io.sundr.model.TypeDef) RichTypeDef(io.sundr.model.RichTypeDef) Test(org.junit.Test)

Aggregations

AdapterContext (io.sundr.adapter.api.AdapterContext)1 Adapters (io.sundr.adapter.api.Adapters)1 ClassWithAnnotation (io.sundr.adapter.testing.general.ClassWithAnnotation)1 ClassWithArray (io.sundr.adapter.testing.general.ClassWithArray)1 ClassWithParam (io.sundr.adapter.testing.general.ClassWithParam)1 ClassWithPrimitiveArray (io.sundr.adapter.testing.general.ClassWithPrimitiveArray)1 ClassWithSelfRefParam (io.sundr.adapter.testing.general.ClassWithSelfRefParam)1 ClassWithSuperClassParam (io.sundr.adapter.testing.general.ClassWithSuperClassParam)1 SimpleClass (io.sundr.adapter.testing.general.SimpleClass)1 StringList (io.sundr.adapter.testing.list.StringList)1 Address (io.sundr.adapter.testing.person.Address)1 Person (io.sundr.adapter.testing.person.Person)1 AnnotationRef (io.sundr.model.AnnotationRef)1 ClassRef (io.sundr.model.ClassRef)1 Method (io.sundr.model.Method)1 PrimitiveRef (io.sundr.model.PrimitiveRef)1 Property (io.sundr.model.Property)1 RichTypeDef (io.sundr.model.RichTypeDef)1 TypeDef (io.sundr.model.TypeDef)1 TypeRef (io.sundr.model.TypeRef)1