Search in sources :

Example 16 with Ds3EnumConstant

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant 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 17 with Ds3EnumConstant

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

the class EnumHelper_Test method testRequiresMatcher.

@Test
public void testRequiresMatcher() {
    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("TypePrefix", null, null, enumConstants);
    final Enum testEnum = EnumConverter.toEnum(testDs3Type);
    assertTrue(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 18 with Ds3EnumConstant

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

the class EnumHelper_Test method testEnumToString.

@Test
public void testEnumToString() {
    final Ds3EnumConstant alpha = new Ds3EnumConstant("Charlie", null);
    final Ds3EnumConstant bravo = new Ds3EnumConstant("Delta", null);
    final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(alpha, bravo);
    final Ds3Type testDs3Type = new Ds3Type("TypePrefix", null, null, enumConstants);
    final Enum testEnum = EnumConverter.toEnum(testDs3Type);
    final String expectedOutput = "    if (input == DS3_TYPE_PREFIX_CHARLIE) {" + "\n" + "        return \"CHARLIE\";" + "\n" + "    } else if (input == DS3_TYPE_PREFIX_DELTA) {" + "\n" + "        return \"DELTA\";" + "\n" + "    } else {" + "\n" + "        return \"\";" + "\n" + "    }" + "\n";
    assertThat(EnumHelper.generateToString(testEnum), is(expectedOutput));
}
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)

Aggregations

Ds3EnumConstant (com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant)18 Test (org.junit.Test)14 Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)9 Enum (com.spectralogic.ds3autogen.c.models.Enum)4 EnumConstant (com.spectralogic.ds3autogen.java.models.EnumConstant)4 EnumConstant (com.spectralogic.ds3autogen.net.model.type.EnumConstant)4 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)3 ImmutableList (com.google.common.collect.ImmutableList)2 Ds3ModelPartialDataFixture.createEmptyDs3Type (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type)1 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HashMap (java.util.HashMap)1