use of org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo in project ballerina by ballerina-lang.
the class AnnotationTest method testStructAnnotation.
@Test(description = "Test struct annotation", enabled = false)
public void testStructAnnotation() {
AnnotationAttributeInfo annotationInfo = (AnnotationAttributeInfo) compileResult.getProgFile().getEntryPackage().getStructInfo("Person").getAttributeInfo(AttributeInfo.Kind.ANNOTATIONS_ATTRIBUTE);
AnnAttachmentInfo[] attachmentInfos = annotationInfo.getAttachmentInfoEntries();
String attributeValue = attachmentInfos[0].getAttributeValue("value").getStringValue();
Assert.assertEquals(attributeValue, "User defined struct : Person");
}
use of org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo in project ballerina by ballerina-lang.
the class AnnotationTest method testParameterAnnotation.
@Test(description = "Test function parameter annotation", enabled = false)
public void testParameterAnnotation() {
AnnotationAttributeInfo annotationInfo = (AnnotationAttributeInfo) compileResult.getProgFile().getEntryPackage().getFunctionInfo("foo").getAttributeInfo(AttributeInfo.Kind.ANNOTATIONS_ATTRIBUTE);
AnnAttachmentInfo[] attachmentInfos = annotationInfo.getAttachmentInfoEntries();
// TODO ParamDef AnnAttachmentInfo are not available at AnnotationAttributeInfo
// String attributeValue = annottations[0].getAttribute("value").getLiteralValue().stringValue();
// Assert.assertEquals(attributeValue, "args: input parameter : type string");
}
use of org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo in project ballerina by ballerina-lang.
the class AnnotationTest method testTransformerAnnotation.
@Test(description = "Test transformer annotation", enabled = false)
public void testTransformerAnnotation() {
AnnotationAttributeInfo annotationInfo = (AnnotationAttributeInfo) compileResult.getProgFile().getEntryPackage().getTransformerInfo("Bar").getAttributeInfo(AttributeInfo.Kind.ANNOTATIONS_ATTRIBUTE);
AnnAttachmentInfo[] attachmentInfos = annotationInfo.getAttachmentInfoEntries();
String attributeValue = attachmentInfos[0].getAttributeValue("value").getStringValue();
Assert.assertEquals(attributeValue, "User defined transformer: from string to Person");
}
use of org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo in project ballerina by ballerina-lang.
the class AnnotationTest method testFunctionAnnotation.
@Test(description = "Test function annotation", enabled = false)
public void testFunctionAnnotation() {
AnnotationAttributeInfo annotationInfo = (AnnotationAttributeInfo) compileResult.getProgFile().getEntryPackage().getFunctionInfo("foo").getAttributeInfo(AttributeInfo.Kind.ANNOTATIONS_ATTRIBUTE);
AnnAttachmentInfo[] attachmentInfos = annotationInfo.getAttachmentInfoEntries();
String attributeValue = attachmentInfos[0].getAttributeValue("value").getStringValue();
Assert.assertEquals(attributeValue, "This is a test function");
AnnAttributeValue firstElement = attachmentInfos[0].getAttributeValue("queryParamValue").getAttributeValueArray()[0];
attributeValue = firstElement.getAnnotationAttachmentValue().getAttributeValue("name").getStringValue();
Assert.assertEquals(attributeValue, "paramName3");
AnnAttributeValue secondElement = attachmentInfos[0].getAttributeValue("queryParamValue").getAttributeValueArray()[1];
attributeValue = secondElement.getAnnotationAttachmentValue().getAttributeValue("name").getStringValue();
Assert.assertEquals(attributeValue, "paramName2");
AnnAttributeValue thirdElement = attachmentInfos[0].getAttributeValue("queryParamValue").getAttributeValueArray()[2];
attributeValue = thirdElement.getAnnotationAttachmentValue().getAttributeValue("name").getStringValue();
Assert.assertEquals(attributeValue, "paramName");
Assert.assertEquals(attachmentInfos[1].getAttributeValue("value").getStringValue(), "test @Args annotation");
}
use of org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo in project ballerina by ballerina-lang.
the class AnnotationTest method testServiceAnnotation.
@Test(description = "Test service annotation", enabled = false)
public void testServiceAnnotation() {
AnnotationAttributeInfo annotationInfo = (AnnotationAttributeInfo) compileResult.getProgFile().getEntryPackage().getServiceInfo("PizzaService").getAttributeInfo(AttributeInfo.Kind.ANNOTATIONS_ATTRIBUTE);
AnnAttachmentInfo[] attachmentInfos = annotationInfo.getAttachmentInfoEntries();
String attributeValue = attachmentInfos[0].getAttributeValue("value").getStringValue();
Assert.assertEquals(attributeValue, "Pizza service");
}
Aggregations