Search in sources :

Example 26 with Ds3Element

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

the class BaseTypeGenerator_Test method getImportsFromDs3Elements_FullList_Test.

@Test
public void getImportsFromDs3Elements_FullList_Test() {
    final ImmutableList<Ds3Element> ds3Elements = ImmutableList.of(new Ds3Element("Name1", "com.spectralogic.test.Type1", "ComponentType1", false), new Ds3Element("Name2", "Type2", "com.spectralogic.test.ComponentType2", false), new Ds3Element("Name3", "Type3", null, false));
    final ImmutableList<String> result = getImportsFromDs3Elements(ds3Elements);
    assertThat(result.size(), is(3));
    assertTrue(result.contains("java.util.List"));
    assertTrue(result.contains("com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper"));
    assertTrue(result.contains("java.util.ArrayList"));
}
Also used : Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 27 with Ds3Element

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

the class BaseTypeGenerator_Test method getAllImports_EnumType_Test.

@Test
public void getAllImports_EnumType_Test() {
    final ImmutableList<Ds3Element> ds3Elements = ImmutableList.of(new Ds3Element("ElementName1", "com.spectralogic.test.ElementType1", "ElementComponentType1", false), new Ds3Element("ElementName2", "ElementType2", "com.spectralogic.test.ElementComponentType2", false), new Ds3Element("ElementName3", "ElementType3", null, false));
    final ImmutableList<Ds3EnumConstant> ds3EnumConstants = ImmutableList.of(new Ds3EnumConstant("EnumConstName1", null), new Ds3EnumConstant("EnumConstName2", null));
    final Ds3Type enumType = new Ds3Type("TypeName", null, ds3Elements, ds3EnumConstants);
    final ImmutableList<String> result = generator.getAllImports(enumType);
    assertThat(result.size(), is(0));
}
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) Test(org.junit.Test)

Example 28 with Ds3Element

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

the class Ds3TypeClassificationUtil_Test method isHttpErrorType_Test.

@Test
public void isHttpErrorType_Test() {
    final ImmutableList<Ds3Element> elements = ImmutableList.of(new Ds3Element("Code", "java.lang.String", null, true), new Ds3Element("HttpErrorCode", "int", null, false), new Ds3Element("Message", "java.lang.String", null, true), new Ds3Element("Resource", "java.lang.String", null, true), new Ds3Element("ResourceId", "long", null, false));
    final Ds3Type errorType = new Ds3Type("com.spectralogic.s3.server.domain.HttpErrorResultApiBean", "Error", elements, null);
    assertTrue(isHttpErrorType(errorType));
    assertFalse(isHttpErrorType(createEmptyDs3Type()));
    assertFalse(isHttpErrorType(createDs3TypeTestData("TestType")));
    assertFalse(isHttpErrorType(createDs3TypeTestData("TestType", elements)));
}
Also used : Ds3ModelPartialDataFixture.createEmptyDs3Type(com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 29 with Ds3Element

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

the class Element method toDs3Element.

public Ds3Element toDs3Element() {
    final ImmutableList<Ds3Annotation> ds3Annotations = toDs3Annotations();
    final Ds3Element ds3Element = new Ds3Element(name, type, componentType, ds3Annotations, isNullableElement(type, ds3Annotations));
    return ds3Element;
}
Also used : Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)

Example 30 with Ds3Element

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

the class BaseTypeGenerator_Test method toElement_EnumElement_Test.

@Test
public void toElement_EnumElement_Test() {
    final Ds3Element ds3Element = new Ds3Element("TestElement", "java.lang.Integer", null, ImmutableList.of(new Ds3Annotation("com.spectralogic.util.bean.lang.Optional", null)), true);
    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) Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) 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