Search in sources :

Example 6 with Ds3Annotation

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.

the class Ds3ElementUtil_Test method hasWrapperAnnotations_HasWrapper_Test.

@Test
public void hasWrapperAnnotations_HasWrapper_Test() {
    final ImmutableList<Ds3AnnotationElement> annotationElements = ImmutableList.of(new Ds3AnnotationElement("CollectionValue", "Nodes", "java.lang.String"), new Ds3AnnotationElement("CollectionValueRenderingMode", "SINGLE_BLOCK_FOR_ALL_ELEMENTS", "com.spectralogic.util.marshal.CustomMarshaledName$CollectionNameRenderingMode"), new Ds3AnnotationElement("Value", "Node", "java.lang.String"));
    final ImmutableList<Ds3Annotation> annotations = ImmutableList.of(new Ds3Annotation("com.spectralogic.util.marshal.CustomMarshaledName", annotationElements));
    assertThat(hasWrapperAnnotations(annotations), is(true));
}
Also used : Ds3AnnotationElement(com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement) Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Test(org.junit.Test)

Example 7 with Ds3Annotation

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.

the class Ds3ElementUtil_Test method hasWrapperAnnotations_NoWrapper_Test.

@Test
public void hasWrapperAnnotations_NoWrapper_Test() {
    final ImmutableList<Ds3AnnotationElement> annotationElements = ImmutableList.of(new Ds3AnnotationElement("CollectionValue", "", "java.lang.String"), new Ds3AnnotationElement("CollectionValueRenderingMode", "UNDEFINED", "com.spectralogic.util.marshal.CustomMarshaledName$CollectionNameRenderingMode"), new Ds3AnnotationElement("Value", "object", "java.lang.String"));
    final ImmutableList<Ds3Annotation> annotations = ImmutableList.of(new Ds3Annotation("com.spectralogic.util.marshal.CustomMarshaledName", annotationElements));
    assertThat(hasWrapperAnnotations(annotations), is(false));
}
Also used : Ds3AnnotationElement(com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement) Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Test(org.junit.Test)

Example 8 with Ds3Annotation

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.

the class Ds3ElementUtil_Test method getXmlTagFromAnnotation_CustomName_Test.

@Test
public void getXmlTagFromAnnotation_CustomName_Test() {
    final Ds3Annotation annotation = createCustomMarshaledNameAnnotation();
    final String result = getXmlTagFromAnnotation(annotation);
    assertThat(result, CoreMatchers.is("Error"));
}
Also used : Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Test(org.junit.Test)

Example 9 with Ds3Annotation

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.

the class Ds3ElementUtil method getXmlTagFromAllAnnotations.

/**
     * Gets the Xml tag name for an element from its list of Ds3Annotations, if one
     * exists. If multiple Xml tag names are found, an exception is thrown.
     */
protected static String getXmlTagFromAllAnnotations(final ImmutableList<Ds3Annotation> annotations, final String elementName) {
    if (isEmpty(annotations)) {
        return "";
    }
    final ImmutableList.Builder<String> builder = ImmutableList.builder();
    for (final Ds3Annotation annotation : annotations) {
        final String curXmlName = getXmlTagFromAnnotation(annotation);
        if (hasContent(curXmlName)) {
            builder.add(curXmlName);
        }
    }
    final ImmutableList<String> xmlNames = builder.build();
    switch(xmlNames.size()) {
        case 0:
            return "";
        case 1:
            return xmlNames.get(0);
        default:
            throw new IllegalArgumentException("There are multiple xml tag names described within the annotations for the element " + elementName + ": " + xmlNames.toString());
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation)

Example 10 with Ds3Annotation

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.

the class NullableVariableUtil_Test method isNullableElement_OptionalAnnotation_Test.

@Test
public void isNullableElement_OptionalAnnotation_Test() {
    final ImmutableList<Ds3Annotation> annotations = ImmutableList.of(new Ds3Annotation("com.spectralogic.util.db.lang.References", null), new Ds3Annotation("com.spectralogic.util.bean.lang.Optional", null));
    assertFalse(isNullableElement(null, ImmutableList.of()));
    assertFalse(isNullableElement("", ImmutableList.of()));
    assertTrue(isNullableElement("MyType", annotations));
    assertTrue(isNullableElement("java.lang.Integer", annotations));
}
Also used : Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Test(org.junit.Test)

Aggregations

Ds3Annotation (com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation)20 Test (org.junit.Test)18 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)9 Ds3AnnotationElement (com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement)7 Element (com.spectralogic.ds3autogen.java.models.Element)2 NetNullableVariable (com.spectralogic.ds3autogen.net.model.common.NetNullableVariable)2 TypeElementList (com.spectralogic.ds3autogen.python.model.type.TypeElementList)2 ImmutableList (com.google.common.collect.ImmutableList)1 Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)1