Search in sources :

Example 6 with Ds3Element

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

the class BaseTypeGenerator_Test method toElementsList_FullList_Test.

@Test
public void toElementsList_FullList_Test() {
    final ImmutableList<Ds3Annotation> optionalAnnotation = ImmutableList.of(new Ds3Annotation("com.spectralogic.util.bean.lang.Optional", null));
    final ImmutableList<Ds3Element> ds3Elements = ImmutableList.of(new Ds3Element("Element1", "java.lang.Integer", null, false), new Ds3Element("Element2", "java.lang.Integer", null, optionalAnnotation, true), new Ds3Element("Element3", "array", "java.lang.Integer", false));
    final ImmutableList<NetNullableVariable> result = generator.toElementsList(ds3Elements, ImmutableMap.of());
    assertThat(result.size(), is(3));
    assertThat(result.get(0).getName(), is("Element1"));
    assertThat(result.get(0).getNetType(), is("int"));
    assertThat(result.get(1).getName(), is("Element2"));
    assertThat(result.get(1).getNetType(), is("int?"));
    assertThat(result.get(2).getName(), is("Element3"));
    assertThat(result.get(2).getNetType(), is("IEnumerable<int>"));
}
Also used : NetNullableVariable(com.spectralogic.ds3autogen.net.model.common.NetNullableVariable) Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 7 with Ds3Element

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

the class BaseTypeGenerator_Test method toElement_SimpleElement_Test.

@Test
public void toElement_SimpleElement_Test() {
    final Ds3Element ds3Element = new Ds3Element("TestElement", "java.lang.Integer", null, false);
    final NetNullableVariable result = generator.toElement(ds3Element, ImmutableMap.of());
    assertThat(result.getName(), is("TestElement"));
    assertThat(result.getNetType(), is("int"));
}
Also used : NetNullableVariable(com.spectralogic.ds3autogen.net.model.common.NetNullableVariable) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 8 with Ds3Element

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

the class NetNullableVariableUtils_Test method getTestTypeMap.

/**
     * Creates a type map with testing values
     */
private static ImmutableMap<String, Ds3Type> getTestTypeMap() {
    final Ds3Type enumType = new Ds3Type("TestEnumType", "", ImmutableList.of(), ImmutableList.of(new Ds3EnumConstant("ONE", null)));
    final Ds3Type elementType = new Ds3Type("TestElementType", ImmutableList.of(new Ds3Element("Element", "int", null, false)));
    return ImmutableMap.of(enumType.getName(), enumType, elementType.getName(), elementType);
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)

Example 9 with Ds3Element

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

the class Ds3SpecParserImpl_Test method blobApiBean.

@Test
public void blobApiBean() throws IOException {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    final Ds3ApiSpec spec = parser.getSpec(Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/blobApiBean.xml"));
    assertThat(spec.getTypes().size(), is(1));
    final Ds3Type blobApiBean = spec.getTypes().get("com.spectralogic.s3.common.platform.domain.BulkObject");
    assertThat(blobApiBean, is(notNullValue()));
    final ImmutableList<Ds3Element> elements = blobApiBean.getElements();
    assertThat(elements.size(), is(7));
    assertThat(elements.get(0).getName(), is("InCache"));
    assertThat(elements.get(0).getNullable(), is(true));
    assertThat(elements.get(1).getName(), is("Latest"));
    assertThat(elements.get(1).getNullable(), is(false));
    assertThat(elements.get(2).getName(), is("Length"));
    assertThat(elements.get(2).getNullable(), is(false));
    assertThat(elements.get(3).getName(), is("Name"));
    assertThat(elements.get(3).getNullable(), is(true));
    assertThat(elements.get(4).getName(), is("Offset"));
    assertThat(elements.get(4).getNullable(), is(false));
    assertThat(elements.get(5).getName(), is("PhysicalPlacement"));
    assertThat(elements.get(5).getNullable(), is(true));
    assertThat(elements.get(6).getName(), is("Version"));
    assertThat(elements.get(6).getNullable(), is(false));
}
Also used : Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 10 with Ds3Element

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

the class BaseTypeParserGenerator_Test method toParseElements_FullList_Test.

@Test
public void toParseElements_FullList_Test() {
    final ImmutableList<Ds3Element> elements = ImmutableList.of(new Ds3Element("Name1", "int", "", false), new Ds3Element("Name2", "Type", "Component", false));
    final ImmutableList<String> result = generator.toParseElements(elements, false);
    assertThat(result.size(), is(2));
    assertThat(result, hasItem("Name1 = ParseInt(element.Element(\"Name1\"))"));
    assertThat(result, hasItem("Name2 = element.Elements(\"Name2\").Select(ParseComponent).ToList()"));
}
Also used : 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