use of com.spectralogic.ds3autogen.c.models.Enum in project ds3_autogen by SpectraLogic.
the class CCodeGenerator_Test method testEnumTypesContainsTargetReadPreferenceType.
@Test
public void testEnumTypesContainsTargetReadPreferenceType() throws IOException, ParseException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(CCodeGenerator_Test.class.getResourceAsStream("/input/3_2_2_contract.xml"));
final ImmutableList<Enum> allEnums = CCodeGenerator.getAllEnums(spec);
final ImmutableSet<String> enumNames = EnumHelper.getEnumNamesSet(allEnums);
assertTrue(enumNames.contains("ds3_target_read_preference_type"));
}
use of com.spectralogic.ds3autogen.c.models.Enum 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.c.models.Enum 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));
}
use of com.spectralogic.ds3autogen.c.models.Enum in project ds3_autogen by SpectraLogic.
the class HeaderConverter_Test method testToHeader.
@Test
public void testToHeader() throws ParseException {
final Ds3DocSpec testDocSpec = new Ds3DocSpecEmptyImpl();
final ImmutableList<Request> allRequests = ImmutableList.of(RequestConverter.toRequest(Ds3ModelFixtures.createBucketRequest(), testDocSpec), RequestConverter.toRequest(Ds3ModelFixtures.deleteBucketRequest(), testDocSpec), RequestConverter.toRequest(Ds3ModelFixtures.getBucketsRequest(), testDocSpec));
final ImmutableList<Enum> allEnums = ImmutableList.of(new Enum("TestEnum", ImmutableList.of("TestEnumValue1", "TestEnumValue2")), new Enum("TestEnum2", ImmutableList.of("TestEnumValue3", "TestEnumValue4")));
final ImmutableList<Struct> allStructs = ImmutableList.of(new Struct("testStruct1", ImmutableList.of(new StructMember(new PrimitiveType("int", false), "structMember1"), new StructMember(new PrimitiveType("ds3_str", true), "structMember2"))), new Struct("testStruct2", "marshallStruct2", ImmutableList.of(new StructMember(new PrimitiveType("int", false), "structMember3")), false, true, false, false));
final Header testHeader = HeaderConverter.toHeader(allEnums, allStructs, allRequests);
assertEquals(testHeader.getEnums(), allEnums);
assertEquals(testHeader.getRequests(), allRequests);
assertEquals(testHeader.getStructs(), allStructs);
}
Aggregations