Search in sources :

Example 16 with AnnAttachmentInfo

use of org.ballerinalang.util.codegen.AnnAttachmentInfo in project ballerina by ballerina-lang.

the class AnnotationTest method testConnectorAnnotation.

@Test(description = "Test connector annotation", enabled = false)
public void testConnectorAnnotation() {
    AnnotationAttributeInfo annotationInfo = (AnnotationAttributeInfo) compileResult.getProgFile().getEntryPackage().getConnectorInfoEntries()[0].getAttributeInfo(AttributeInfo.Kind.ANNOTATIONS_ATTRIBUTE);
    AnnAttachmentInfo[] attachmentInfos = annotationInfo.getAttachmentInfoEntries();
    String attributeValue = attachmentInfos[0].getAttributeValue("value").getStringValue();
    Assert.assertEquals(attributeValue, "Test connector");
}
Also used : AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) AnnotationAttributeInfo(org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo) Test(org.testng.annotations.Test)

Example 17 with AnnAttachmentInfo

use of org.ballerinalang.util.codegen.AnnAttachmentInfo in project ballerina by ballerina-lang.

the class AnnotationTest method testResourceAnnotation.

@Test(description = "Test resource annotation", enabled = false)
public void testResourceAnnotation() {
    AnnotationAttributeInfo annotationInfo = (AnnotationAttributeInfo) compileResult.getProgFile().getEntryPackage().getServiceInfo("PizzaService").getResourceInfoEntries()[1].getAttributeInfo(AttributeInfo.Kind.ANNOTATIONS_ATTRIBUTE);
    AnnAttachmentInfo[] attachmentInfos = annotationInfo.getAttachmentInfoEntries();
    String attributeValue = attachmentInfos[0].getAttributeValue("value").getStringValue();
    Assert.assertEquals(attributeValue, "Order pizza");
    annotationInfo = (AnnotationAttributeInfo) compileResult.getProgFile().getEntryPackage().getServiceInfo("PizzaService").getResourceInfoEntries()[0].getAttributeInfo(AttributeInfo.Kind.ANNOTATIONS_ATTRIBUTE);
    attachmentInfos = annotationInfo.getAttachmentInfoEntries();
    attributeValue = attachmentInfos[0].getAttributeValue("value").getStringValue();
    Assert.assertEquals(attributeValue, "Check order status");
// TODO ParamDef AnnAttachmentInfo are not available at AnnotationAttributeInfo
// String paramAnnotVal = orderPizzaResource.getParameterDefs()[0].getAnnotations()[0].getValue();
// Assert.assertEquals(paramAnnotVal, "input parameter for oderPizza resource");
}
Also used : AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) AnnotationAttributeInfo(org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo) Test(org.testng.annotations.Test)

Example 18 with AnnAttachmentInfo

use of org.ballerinalang.util.codegen.AnnAttachmentInfo 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 19 with AnnAttachmentInfo

use of org.ballerinalang.util.codegen.AnnAttachmentInfo 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 20 with AnnAttachmentInfo

use of org.ballerinalang.util.codegen.AnnAttachmentInfo 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)

Aggregations

AnnAttachmentInfo (org.ballerinalang.util.codegen.AnnAttachmentInfo)31 AnnAttributeValue (org.ballerinalang.util.codegen.AnnAttributeValue)17 ParamAnnAttachmentInfo (org.ballerinalang.util.codegen.ParamAnnAttachmentInfo)10 AnnotationAttributeInfo (org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo)10 Test (org.testng.annotations.Test)10 AnnAttributeKeyValuePair (org.ballerinalang.util.codegen.AnnAttributeKeyValuePair)7 HashMap (java.util.HashMap)5 LinkedList (java.util.LinkedList)3 ExternalDocs (io.swagger.models.ExternalDocs)2 Scheme (io.swagger.models.Scheme)2 BodyParameter (io.swagger.models.parameters.BodyParameter)2 PathParameter (io.swagger.models.parameters.PathParameter)2 QueryParameter (io.swagger.models.parameters.QueryParameter)2 Contact (io.swagger.models.Contact)1 Info (io.swagger.models.Info)1 License (io.swagger.models.License)1 Model (io.swagger.models.Model)1 ModelImpl (io.swagger.models.ModelImpl)1 RefModel (io.swagger.models.RefModel)1 Response (io.swagger.models.Response)1