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