use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteParameterOfMethod.
@Test
public void testDeleteParameterOfMethod() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod method = adobada.getMethod("m4", factory.Type().INTEGER_PRIMITIVE, factory.Type().FLOAT_PRIMITIVE, factory.Type().STRING);
final CtParameter param = (CtParameter) method.getParameters().get(1);
assertEquals(3, method.getParameters().size());
param.delete();
assertEquals(2, method.getParameters().size());
assertFalse(method.getParameters().contains(param));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteAnnotationOnAClass.
@Test
public void testDeleteAnnotationOnAClass() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
assertEquals(1, adobada.getAnnotations().size());
final CtAnnotation<? extends Annotation> annotation = adobada.getAnnotations().get(0);
annotation.delete();
assertEquals(0, adobada.getAnnotations().size());
assertFalse(adobada.getAnnotations().contains(annotation));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteAClassTopLevel.
@Test
public void testDeleteAClassTopLevel() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtPackage aPackage = adobada.getParent(CtPackage.class);
assertEquals(1, aPackage.getTypes().size());
adobada.delete();
assertEquals(0, aPackage.getTypes().size());
assertFalse(aPackage.getTypes().contains(adobada));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteAStatementInAnonymousExecutable.
@Test
public void testDeleteAStatementInAnonymousExecutable() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final List<CtAnonymousExecutable> anonymousExecutables = adobada.getAnonymousExecutables();
final CtAnonymousExecutable instanceExec = anonymousExecutables.get(0);
assertEquals(2, instanceExec.getBody().getStatements().size());
final CtStatement statement = instanceExec.getBody().getStatement(1);
statement.delete();
assertEquals(1, instanceExec.getBody().getStatements().size());
assertFalse(instanceExec.getBody().getStatements().contains(statement));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteBodyOfAMethod.
@Test
public void testDeleteBodyOfAMethod() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod method = adobada.getMethod("m");
assertNotNull(method.getBody());
method.getBody().delete();
assertNull(method.getBody());
}
Aggregations