Search in sources :

Example 6 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 7 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 8 with Ds3EnumConstant

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

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

the class BaseTypeGenerator_Test method getEnumConstants_FullList_Test.

@Test
public void getEnumConstants_FullList_Test() {
    final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(new Ds3EnumConstant("one", null), new Ds3EnumConstant("two", null), new Ds3EnumConstant("three", null));
    final ImmutableList<EnumConstant> result = getEnumConstantsList(enumConstants);
    assertThat(result.size(), is(3));
    assertThat(result.get(0).getName(), is("one"));
    assertThat(result.get(1).getName(), is("two"));
    assertThat(result.get(2).getName(), is("three"));
}
Also used : Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) EnumConstant(com.spectralogic.ds3autogen.net.model.type.EnumConstant) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Test(org.junit.Test)

Example 10 with Ds3EnumConstant

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

the class BaseTypeGenerator_Test method toEnumConstants_FullList_Test.

@Test
public void toEnumConstants_FullList_Test() {
    final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(new Ds3EnumConstant("one", null), new Ds3EnumConstant("two", null), new Ds3EnumConstant("three", null));
    final ImmutableList<EnumConstant> result = generator.toEnumConstantsList(enumConstants);
    assertThat(result.size(), is(3));
    assertThat(result.get(0).getName(), is("one"));
    assertThat(result.get(1).getName(), is("two"));
    assertThat(result.get(2).getName(), is("three"));
}
Also used : Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) EnumConstant(com.spectralogic.ds3autogen.net.model.type.EnumConstant) 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