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));
}
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());
}
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));
}
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();
}
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)));
}
Aggregations