//1.1 Metadata collection
byte[] origin = ManipulatorTest.getBytesFromFile(new File("target/test-classes/test/PlentyOfAnnotations.class"));
MiniStore store = new MiniStore()
.addClassToStore("test.PlentyOfAnnotations",
origin);
AnnotationMetadataProvider provider = new AnnotationMetadataProvider(store, reporter);
List<Element> originalMetadata = provider.getMetadatas();
// 1.2 Manipulation
Manipulator manipulator = new Manipulator(this.getClass().getClassLoader());
manipulator.prepare(origin);
byte[] clazz = manipulator.manipulate(origin);
Element originalManipulationMetadata = manipulator.getManipulationMetadata();
// 1.3 Check that the class is valid
ManipulatedClassLoader classloader = new ManipulatedClassLoader("test.PlentyOfAnnotations", clazz);
Class cl = classloader.findClass("test.PlentyOfAnnotations");
Assert.assertNotNull(cl);
// ---------------
// Step 2 - Second collection and manipulation
// We use the output class as entry.
// 2.1 Metadata collection
store = new MiniStore().addClassToStore("test.PlentyOfAnnotations", clazz);
provider = new AnnotationMetadataProvider(store, reporter);
List<Element> metadataAfterOneManipulation = provider.getMetadatas();
// 2.2 Manipulation
manipulator = new Manipulator(this.getClass().getClassLoader());
manipulator.prepare(clazz);
byte[] clazz2 = manipulator.manipulate(clazz);
Element manipulationMetadataAfterSecondManipulation = manipulator.getManipulationMetadata();
// 2.3 Check that the class is valid
classloader = new ManipulatedClassLoader("test.PlentyOfAnnotations", clazz);
cl = classloader.findClass("test.PlentyOfAnnotations");
Assert.assertNotNull(cl);
// ---------------
// Step 3 - Third collection and manipulation
// We use the output class of 2 as entry.
// 3.1 Metadata collection
store = new MiniStore().addClassToStore("test.PlentyOfAnnotations", clazz2);
provider = new AnnotationMetadataProvider(store, reporter);
List<Element> metadataAfterTwoManipulation = provider.getMetadatas();
// 3.2 Manipulation
manipulator = new Manipulator(this.getClass().getClassLoader());
manipulator.prepare(clazz2);
byte[] clazz3 = manipulator.manipulate(clazz2);
Element manipulationMetadataAfterThirdManipulation = manipulator.getManipulationMetadata();