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>"));
}
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"));
}
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);
}
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));
}
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()"));
}
Aggregations