Search in sources :

Example 6 with AnnotationAttributeInfo

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");
}
Also used : AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) AnnotationAttributeInfo(org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo) Test(org.testng.annotations.Test)

Example 7 with AnnotationAttributeInfo

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");
}
Also used : AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) AnnotationAttributeInfo(org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo) Test(org.testng.annotations.Test)

Example 8 with AnnotationAttributeInfo

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");
}
Also used : AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) AnnotationAttributeInfo(org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo) Test(org.testng.annotations.Test)

Example 9 with AnnotationAttributeInfo

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");
}
Also used : AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) AnnAttributeValue(org.ballerinalang.util.codegen.AnnAttributeValue) AnnotationAttributeInfo(org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo) Test(org.testng.annotations.Test)

Example 10 with AnnotationAttributeInfo

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");
}
Also used : AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) AnnotationAttributeInfo(org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo) Test(org.testng.annotations.Test)

Aggregations

AnnAttachmentInfo (org.ballerinalang.util.codegen.AnnAttachmentInfo)10 AnnotationAttributeInfo (org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo)10 Test (org.testng.annotations.Test)10 AnnAttributeValue (org.ballerinalang.util.codegen.AnnAttributeValue)2 CompileResult (org.ballerinalang.launcher.util.CompileResult)1