Search in sources :

Example 1 with Ds3Type

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

the class PythonCodeGenerator_Test method toTypeDescriptorList_FullMap_Test.

@Test
public void toTypeDescriptorList_FullMap_Test() {
    final Ds3Type ds3Type = createDs3TypeTestData("com.test.SimpleType", createDs3ElementListTestData("ElementName", "ElementType"));
    final ImmutableMap<String, Ds3Type> testTypeMap = ImmutableMap.of(ds3Type.getName(), ds3Type);
    final ImmutableList<TypeDescriptor> result = toTypeDescriptorList(testTypeMap);
    assertThat(result.size(), is(1));
    assertThat(result.get(0).getName(), is("SimpleType"));
}
Also used : TypeDescriptor(com.spectralogic.ds3autogen.python.model.type.TypeDescriptor) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Test(org.junit.Test)

Example 2 with Ds3Type

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

the class CCodeGenerator method getAllStructs.

public static ImmutableList<Struct> getAllStructs(final Ds3ApiSpec spec, final ImmutableSet<String> enumNames, final ImmutableSet<String> responseTypes, final ImmutableSet<String> embeddedTypes, final ImmutableSet<String> arrayMemberTypes, final ImmutableSet<String> paginatedTypes) throws ParseException {
    final ImmutableList.Builder<Struct> allStructsBuilder = ImmutableList.builder();
    if (ConverterUtil.hasContent(spec.getTypes())) {
        for (final Ds3Type ds3TypeEntry : spec.getTypes().values()) {
            if (ConverterUtil.hasContent(ds3TypeEntry.getEnumConstants()))
                continue;
            final Struct structEntry = StructConverter.toStruct(ds3TypeEntry, enumNames, responseTypes, embeddedTypes, arrayMemberTypes, paginatedTypes);
            allStructsBuilder.add(structEntry);
        }
    }
    return allStructsBuilder.build();
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) ImmutableList(com.google.common.collect.ImmutableList)

Example 3 with Ds3Type

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

the class EnumHelper_Test method testGetEnumValues.

@Test
public void testGetEnumValues() {
    final Ds3EnumConstant alpha = new Ds3EnumConstant("Alpha", null);
    final Ds3EnumConstant bravo = new Ds3EnumConstant("Bravo", null);
    final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(alpha, bravo);
    final Ds3Type testDs3Type = new Ds3Type("Type", null, null, enumConstants);
    final ImmutableList<String> stringsList = EnumHelper.convertDs3EnumConstants(testDs3Type);
    final String expectedResult = "    DS3_TYPE_ALPHA,\n" + "    DS3_TYPE_BRAVO";
    final String result = EnumHelper.getEnumValues(stringsList);
    assertThat(result, is(expectedResult));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Test(org.junit.Test)

Example 4 with Ds3Type

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

the class EnumHelper_Test method testDoesNotRequireMatcher.

@Test
public void testDoesNotRequireMatcher() {
    final Ds3EnumConstant alpha = new Ds3EnumConstant("Alpha", null);
    final Ds3EnumConstant bravo = new Ds3EnumConstant("Bravo", null);
    final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(alpha, bravo);
    final Ds3Type testDs3Type = new Ds3Type("com.spectralogic.util.db.lang.SqlOperation", null, null, enumConstants);
    final Enum testEnum = EnumConverter.toEnum(testDs3Type);
    assertFalse(testEnum.requiresMatcher());
}
Also used : Enum(com.spectralogic.ds3autogen.c.models.Enum) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Test(org.junit.Test)

Example 5 with Ds3Type

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

the class EnumHelper_Test method testConvertDs3EnumConstants.

@Test
public void testConvertDs3EnumConstants() {
    final Ds3EnumConstant alpha = new Ds3EnumConstant("Alpha", null);
    final Ds3EnumConstant bravo = new Ds3EnumConstant("Bravo", null);
    final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(alpha, bravo);
    final Ds3Type testDs3Type = new Ds3Type("Type", null, null, enumConstants);
    final ImmutableList<String> stringsList = EnumHelper.convertDs3EnumConstants(testDs3Type);
    assertFalse(stringsList.isEmpty());
    assertEquals(2, stringsList.size());
    assertEquals("DS3_TYPE_ALPHA", stringsList.get(0));
    assertEquals("DS3_TYPE_BRAVO", stringsList.get(1));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Test(org.junit.Test)

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