Search in sources :

Example 21 with Ds3Type

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

the class Ds3TypeClassificationUtil_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 : Ds3ModelPartialDataFixture.createEmptyDs3Type(com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type) 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 22 with Ds3Type

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

the class Ds3TypeClassificationUtil_Test method getElementNames_Test.

@Test
public void getElementNames_Test() {
    final ImmutableList<Ds3Element> elements = ImmutableList.of(new Ds3Element("Code", "java.lang.String", null, true), new Ds3Element("HttpErrorCode", "int", null, false));
    final Ds3Type type = createDs3TypeTestData("TestType", elements);
    final ImmutableList<String> result = getElementNames(type);
    assertThat(result.size(), is(2));
    assertTrue(result.contains("Code"));
    assertTrue(result.contains("HttpErrorCode"));
}
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 23 with Ds3Type

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

the class Ds3TypeClassificationUtil_Test method containsElement_Test.

@Test
public void containsElement_Test() {
    final ImmutableList<Ds3Element> elements = ImmutableList.of(new Ds3Element("Code", "java.lang.String", null, true), new Ds3Element("HttpErrorCode", "int", null, false));
    final Ds3Type type = createDs3TypeTestData("TestType", elements);
    assertTrue(containsElement(type, "Code"));
    assertTrue(containsElement(type, "HttpErrorCode"));
    assertFalse(containsElement(type, "Resource"));
    assertFalse(containsElement(type, "ResourceId"));
}
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 24 with Ds3Type

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

the class BaseTypeGenerator_Test method toElementList_Jobs_Test.

@Test
public void toElementList_Jobs_Test() {
    final ImmutableList<Ds3AnnotationElement> annotations = ImmutableList.of(new Ds3AnnotationElement("CollectionValue", "Jobs", "java.lang.String"), new Ds3AnnotationElement("CollectionValueRenderingMode", "SINGLE_BLOCK_FOR_ALL_ELEMENTS", "com.spectralogic.util.marshal.CustomMarshaledName$CollectionNameRenderingMode"), new Ds3AnnotationElement("Value", "Job", "java.lang.String"));
    final Ds3Element jobs = new Ds3Element("Jobs", "array", "com.spectralogic.s3.server.domain.Job", ImmutableList.of(new Ds3Annotation("com.spectralogic.util.marshal.CustomMarshaledName", annotations)), false);
    final Ds3Type jobApiBean = createDs3TypeTestData("com.spectralogic.s3.server.domain.Job");
    final TypeElementList result = toElementList(jobs, ImmutableMap.of(jobApiBean.getName(), jobApiBean));
    assertThat(result.toPythonCode(), is("('Job', None, Job())"));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) 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 25 with Ds3Type

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

the class BaseTypeGenerator_Test method createTestTypeMap.

/**
     * Creates the test TypeMap
     */
private static ImmutableMap<String, Ds3Type> createTestTypeMap() {
    final Ds3Type listType = createDs3TypeTestData("com.test.ListType");
    final Ds3Type elementType = createDs3TypeTestData("com.test.ElementType");
    return ImmutableMap.of(listType.getName(), listType, elementType.getName(), elementType);
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)

Aggregations

Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)44 Test (org.junit.Test)37 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)22 Ds3EnumConstant (com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant)9 Enum (com.spectralogic.ds3autogen.c.models.Enum)6 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)5 Ds3ModelPartialDataFixture.createEmptyDs3Type (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)4 Struct (com.spectralogic.ds3autogen.c.models.Struct)4 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 ImmutableList (com.google.common.collect.ImmutableList)3 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)2 NameMapper (com.spectralogic.ds3autogen.NameMapper)2 Ds3DocSpecParser (com.spectralogic.ds3autogen.api.Ds3DocSpecParser)2 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)2 SourceConverter (com.spectralogic.ds3autogen.c.converters.SourceConverter)2 StructConverter (com.spectralogic.ds3autogen.c.converters.StructConverter)2 EnumHelper (com.spectralogic.ds3autogen.c.helpers.EnumHelper)2