Search in sources :

Example 1 with Ds3EnumConstant

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

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

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

Example 4 with Ds3EnumConstant

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

the class NoneEnumGenerator method toEnumConstantsList.

/**
     * Converts a list of Ds3EnumConstants into a list of Enum Constants and
     * adds the enum constant NONE
     */
@Override
public ImmutableList<EnumConstant> toEnumConstantsList(final ImmutableList<Ds3EnumConstant> ds3EnumConstants) {
    final ImmutableList.Builder<EnumConstant> builder = ImmutableList.builder();
    builder.addAll(getEnumConstantsList(ds3EnumConstants));
    builder.add(new EnumConstant("NONE"));
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) EnumConstant(com.spectralogic.ds3autogen.net.model.type.EnumConstant) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant)

Example 5 with Ds3EnumConstant

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

the class BaseTypeGenerator_Test method toEnumConstantsList_FullList_Test.

@Test
public void toEnumConstantsList_FullList_Test() {
    final ImmutableList<String> expectedEnums = ImmutableList.of("ONE", "TWO", "THREE");
    final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(new Ds3EnumConstant("one", ImmutableList.of()), new Ds3EnumConstant("Two", ImmutableList.of()), new Ds3EnumConstant("THREE", ImmutableList.of()));
    final ImmutableList<String> result = generator.toEnumConstantsList(enumConstants);
    assertThat(result.size(), is(expectedEnums.size()));
    expectedEnums.forEach(expected -> assertThat(result, hasItem(expected)));
}
Also used : 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