Search in sources :

Example 1 with Ds3Element

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

the class BaseTypeGenerator_Test method toElementList_CommonPrefixes_Test.

@Test
public void toElementList_CommonPrefixes_Test() {
    final ImmutableList<Ds3AnnotationElement> annotations = ImmutableList.of(new Ds3AnnotationElement("CollectionValue", "CommonPrefixes", "java.lang.String"), new Ds3AnnotationElement("CollectionValueRenderingMode", "BLOCK_FOR_EVERY_ELEMENT", "com.spectralogic.util.marshal.CustomMarshaledName$CollectionNameRenderingMode"), new Ds3AnnotationElement("Value", "Prefix", "java.lang.String"));
    final Ds3Element commonPrefixes = new Ds3Element("CommonPrefixes", "array", "java.lang.String", ImmutableList.of(new Ds3Annotation("com.spectralogic.util.marshal.CustomMarshaledName", annotations)), false);
    final TypeElementList result = toElementList(commonPrefixes, ImmutableMap.of());
    assertThat(result.toPythonCode(), is("('CommonPrefixes', None, CommonPrefixes())"));
}
Also used : Ds3AnnotationElement(com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Test(org.junit.Test)

Example 2 with Ds3Element

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

the class C_Type_Test method testStructMemberTypeUuidToString.

@Test
public void testStructMemberTypeUuidToString() throws java.text.ParseException {
    final Ds3Element testElement = new Ds3Element("uuidElement", "java.util.UUID", null, false);
    final C_Type c_type = C_TypeHelper.convertDs3ElementType(testElement, ImmutableSet.of());
    assertThat(c_type.getTypeName(), is("ds3_str"));
    assertThat(c_type.toString(), is("ds3_str*"));
}
Also used : C_Type(com.spectralogic.ds3autogen.c.models.C_Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 3 with Ds3Element

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

the class StructConverter method convertDs3Elements.

private static ImmutableList<StructMember> convertDs3Elements(final ImmutableList<Ds3Element> elementsList, final ImmutableSet<String> enumNames, final boolean isPaginated) throws ParseException {
    final ImmutableList.Builder<StructMember> builder = ImmutableList.builder();
    for (final Ds3Element currentElement : elementsList) {
        final C_Type elementType = C_TypeHelper.convertDs3ElementType(currentElement, enumNames);
        builder.add(new StructMember(elementType, StructHelper.getNameUnderscores(currentElement.getName()), Ds3ElementUtil.getXmlTagName(currentElement), Ds3ElementUtil.getEncapsulatingTagAnnotations(currentElement.getDs3Annotations()), Ds3ElementUtil.isAttribute(currentElement.getDs3Annotations()), hasWrapper(currentElement)));
        if (elementType.isArray()) {
            builder.add(new StructMember(new PrimitiveType("size_t", false), "num_" + StructHelper.getNameUnderscores(currentElement.getName())));
        }
        if (isPaginated) {
            builder.add(new StructMember(new FreeableType("ds3_paging", false), "paging"));
        }
    }
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)

Example 4 with Ds3Element

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

the class C_Type_Test method testStructTypeDs3ResponseToString.

@Test
public void testStructTypeDs3ResponseToString() throws java.text.ParseException {
    final Ds3Element testElement = new Ds3Element("BuildInformation", "com.spectralogic.s3.common.platform.lang.BuildInformation", null, false);
    final C_Type c_type = C_TypeHelper.convertDs3ElementType(testElement, ImmutableSet.of());
    assertThat(c_type.getTypeName(), is("ds3_build_information_response"));
    assertThat(c_type.toString(), is("ds3_build_information_response*"));
}
Also used : C_Type(com.spectralogic.ds3autogen.c.models.C_Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 5 with Ds3Element

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

the class C_Type_Test method testStructMemberTypeStringToString.

@Test
public void testStructMemberTypeStringToString() throws java.text.ParseException {
    final Ds3Element testElement = new Ds3Element("stringElement", "java.lang.String", null, false);
    final C_Type c_type = C_TypeHelper.convertDs3ElementType(testElement, ImmutableSet.of());
    assertThat(c_type.getTypeName(), is("ds3_str"));
    assertThat(c_type.toString(), is("ds3_str*"));
}
Also used : C_Type(com.spectralogic.ds3autogen.c.models.C_Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Aggregations

Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)54 Test (org.junit.Test)48 Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)22 C_Type (com.spectralogic.ds3autogen.c.models.C_Type)10 Ds3Annotation (com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation)9 Element (com.spectralogic.ds3autogen.java.models.Element)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 Ds3AnnotationElement (com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement)5 ImmutableList (com.google.common.collect.ImmutableList)4 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)4 Struct (com.spectralogic.ds3autogen.c.models.Struct)4 NetNullableVariable (com.spectralogic.ds3autogen.net.model.common.NetNullableVariable)4 Ds3ModelPartialDataFixture.createEmptyDs3Type (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type)4 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)3 Ds3EnumConstant (com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant)3 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)2 NameMapper (com.spectralogic.ds3autogen.NameMapper)2 Ds3DocSpecParser (com.spectralogic.ds3autogen.api.Ds3DocSpecParser)2