Search in sources :

Example 1 with CtElementPathBuilder

use of spoon.reflect.path.CtElementPathBuilder in project spoon by INRIA.

the class PathTest method testGetPathFromNonParent.

@Test
public void testGetPathFromNonParent() throws Exception {
    CtMethod fooMethod = (CtMethod) new CtPathStringBuilder().fromString(".spoon.test.path.Foo.foo").evaluateOn(factory.getModel().getRootPackage()).iterator().next();
    CtMethod barMethod = (CtMethod) new CtPathStringBuilder().fromString(".spoon.test.path.Foo.bar").evaluateOn(factory.getModel().getRootPackage()).iterator().next();
    try {
        new CtElementPathBuilder().fromElement(fooMethod, barMethod);
        fail("No path should be found to .spoon.test.path.Foo.foo from .spoon.test.path.Foo.bar");
    } catch (CtPathException e) {
    }
}
Also used : CtPathStringBuilder(spoon.reflect.path.CtPathStringBuilder) CtMethod(spoon.reflect.declaration.CtMethod) CtElementPathBuilder(spoon.reflect.path.CtElementPathBuilder) CtPathException(spoon.reflect.path.CtPathException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CtMethod (spoon.reflect.declaration.CtMethod)1 CtElementPathBuilder (spoon.reflect.path.CtElementPathBuilder)1 CtPathException (spoon.reflect.path.CtPathException)1 CtPathStringBuilder (spoon.reflect.path.CtPathStringBuilder)1