More assertions
This commit is contained in:
@@ -15,6 +15,11 @@ public class Annotations extends Attribute
|
||||
{
|
||||
super(attributes, AttributeType.RUNTIMEVISIBLEANNOTATIONS);
|
||||
}
|
||||
|
||||
public List<Annotation> getAnnotations()
|
||||
{
|
||||
return annotations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAttribute(DataInputStream is) throws IOException
|
||||
|
||||
@@ -24,6 +24,16 @@ public class Annotation
|
||||
{
|
||||
return annotations;
|
||||
}
|
||||
|
||||
public Type getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<Element> getElements()
|
||||
{
|
||||
return elements;
|
||||
}
|
||||
|
||||
public void load(DataInputStream is) throws IOException
|
||||
{
|
||||
|
||||
@@ -16,6 +16,21 @@ public class Element
|
||||
{
|
||||
this.annotation = annotation;
|
||||
}
|
||||
|
||||
public Annotation getAnnotation()
|
||||
{
|
||||
return annotation;
|
||||
}
|
||||
|
||||
public Type getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public void load(DataInputStream is) throws IOException
|
||||
{
|
||||
|
||||
@@ -5,8 +5,16 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import net.runelite.deob.ClassFile;
|
||||
import net.runelite.deob.ClassGroup;
|
||||
import net.runelite.deob.Method;
|
||||
import net.runelite.deob.attributes.Annotations;
|
||||
import net.runelite.deob.attributes.AttributeType;
|
||||
import net.runelite.deob.attributes.annotation.Annotation;
|
||||
import net.runelite.deob.attributes.annotation.Element;
|
||||
import net.runelite.deob.signature.Type;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -30,6 +38,23 @@ public class AnnotationTest
|
||||
// parse it again
|
||||
cf = new ClassFile(group, new DataInputStream(new ByteArrayInputStream(bout.toByteArray())));
|
||||
|
||||
System.out.println(cf);
|
||||
Method method = cf.getMethods().getMethods().get(1);
|
||||
Assert.assertEquals("method1", method.getName());
|
||||
|
||||
Annotations annotations = (Annotations) method.getAttributes().findType(AttributeType.RUNTIMEVISIBLEANNOTATIONS);
|
||||
Assert.assertNotNull(annotations);
|
||||
|
||||
Optional<Annotation> annotation = annotations.getAnnotations().stream().filter(a -> a.getType().equals(new Type("Lnet/runelite/deob/annotations/MyAnnotation;"))).findFirst();
|
||||
Assert.assertTrue(annotation.isPresent());
|
||||
|
||||
Annotation an = annotation.get();
|
||||
List<Element> elements = an.getElements();
|
||||
|
||||
Assert.assertEquals(1, elements.size());
|
||||
|
||||
Element element = elements.get(0);
|
||||
|
||||
Assert.assertEquals("value", element.getType().toString());
|
||||
Assert.assertEquals("method1", element.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user