Search in sources :

Example 1 with CtAnnotationImpl

use of spoon.support.reflect.declaration.CtAnnotationImpl in project spoon by INRIA.

the class ElementTest method testGetFactory.

@Test
public void testGetFactory() {
    // contract: getFactory should always return an object
    // even if an element is created via its constructor
    // and not through the factory
    Launcher spoon = new Launcher();
    CtElement element = spoon.getFactory().createAnnotation();
    assertNotNull(element.getFactory());
    CtElement otherElement = new CtAnnotationImpl<>();
    assertNotNull(otherElement.getFactory());
    CtElement yetAnotherOne = new CtMethodImpl<>();
    assertNotNull(yetAnotherOne.getFactory());
    // contract: a singleton is used for the default factory
    assertSame(otherElement.getFactory(), yetAnotherOne.getFactory());
}
Also used : CtElement(spoon.reflect.declaration.CtElement) CtMethodImpl(spoon.support.reflect.declaration.CtMethodImpl) Launcher(spoon.Launcher) CtAnnotationImpl(spoon.support.reflect.declaration.CtAnnotationImpl) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Launcher (spoon.Launcher)1 CtElement (spoon.reflect.declaration.CtElement)1 CtAnnotationImpl (spoon.support.reflect.declaration.CtAnnotationImpl)1 CtMethodImpl (spoon.support.reflect.declaration.CtMethodImpl)1