use of javassist.CtClass in project javassist-maven-plugin by icon-Systemhaus-GmbH.
the class TestJavassistTransformerExecutor_transform method use_input_directory_if_output_directory_is_null.
@Test
public void use_input_directory_if_output_directory_is_null() throws Exception {
// given
final String className = oneTestClass();
final CtClass candidateClass = stampedClass(className);
// use input if output is not set
candidateClass.writeFile(eq(classDirectory().getAbsolutePath()));
configureClassPool(this.classPool).importPackage(className);
expectLastCall();
expect(this.classPool.get(className)).andReturn(candidateClass);
expect(this.classTransformer.shouldTransform(same(candidateClass))).andReturn(true);
this.classTransformer.applyTransformations(same(candidateClass));
expectLastCall();
replay(candidateClass, this.classPool, this.classTransformer);
// when
sut.transform(this.classTransformer, classDirectory().getAbsolutePath(), null);
// then
verify(candidateClass, this.classPool, this.classTransformer);
}
use of javassist.CtClass in project javassist-maven-plugin by icon-Systemhaus-GmbH.
the class TestJavassistTransformerExecutor_transform method stampedClass.
private CtClass stampedClass(final String className) throws CannotCompileException, NotFoundException {
final CtClass candidateClass = super.stampedClass(className, initializeClass(mock("candidateClass", CtClass.class)));
expect(candidateClass.getNestedClasses()).andReturn(new CtClass[0]);
return candidateClass;
}
use of javassist.CtClass in project javassist-maven-plugin by icon-Systemhaus-GmbH.
the class TestJavassistTransformerExecutor_transform method transform_stamp_and_write_class.
@Test
public void transform_stamp_and_write_class() throws Exception {
// given
final String className = oneTestClass();
final Iterator<String> classNames = classNames(className);
final CtClass candidateClass = stampedClass(className);
candidateClass.writeFile(eq(transformedClassDirectory().getAbsolutePath()));
configureClassPool(this.classPool).importPackage(className);
expectLastCall();
expect(this.classPool.get(className)).andReturn(candidateClass);
expect(this.classTransformer.shouldTransform(same(candidateClass))).andReturn(true);
this.classTransformer.applyTransformations(same(candidateClass));
expectLastCall();
replay(candidateClass, classNames, this.classPool, this.classTransformer);
// when
sut.transform(this.classTransformer, classDirectory().getAbsolutePath(), transformedClassDirectory().getAbsolutePath(), classNames);
// then
verify(candidateClass, classNames, this.classPool, this.classTransformer);
}
use of javassist.CtClass in project javassist-maven-plugin by icon-Systemhaus-GmbH.
the class TestJavassistTransformerExecutor_transform_with_nested_classes method stampedClassWithNestedClasses.
private CtClass stampedClassWithNestedClasses(final String className, final CtClass... nestedClasses) throws CannotCompileException, NotFoundException, IOException {
final CtClass candidateClass = super.stampedClass(className, initializeClass(mock("candidateClass", CtClass.class)));
candidateClass.writeFile(eq(transformedClassDirectory().getAbsolutePath()));
expect(candidateClass.getNestedClasses()).andReturn(nestedClasses);
return candidateClass;
}
use of javassist.CtClass in project javassist-maven-plugin by icon-Systemhaus-GmbH.
the class TestJavassistTransformerExecutor_transform_with_nested_classes method do_nothing_if_nestedClass_is_stamped.
@Test
public void do_nothing_if_nestedClass_is_stamped() throws Exception {
// given
final String className = oneTestClass();
final CtClass nestedClass = mock("nestedClass", CtClass.class);
expect(nestedClass.isModified()).andReturn(true);
expect(nestedClass.getDeclaredField(startsWith(STAMP_FIELD_NAME))).andReturn(mock("nestedClass_stampField", CtField.class));
final Iterator<String> classNames = classNames(className);
final CtClass candidateClass = configureCandidateClassFoTransformation(className, stampedClassWithNestedClasses(className, nestedClass));
replay(nestedClass, candidateClass, classNames, this.classPool, this.classTransformer);
// when
executeTransform(classNames);
// then
verify(nestedClass, candidateClass, classNames, this.classPool, this.classTransformer);
}
Aggregations