use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class StructConverter_Test method testConvertNameToMarshallCommonPrefixSpecialCase.
@Test
public void testConvertNameToMarshallCommonPrefixSpecialCase() throws ParseException {
final Ds3Element testElement1 = new Ds3Element("CommonPrefixes", "array", "java.lang.String", false);
final ImmutableList<Ds3Element> elementsList = ImmutableList.of(testElement1);
final Ds3Type ds3Type = new Ds3Type("com.spectralogic.s3.server.domain.BucketObjectsApiBean", "ListBucketResult", elementsList, ImmutableList.of());
final Struct testStruct = StructConverter.toStruct(ds3Type, ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of());
assertThat(testStruct.getNameToMarshall(), is("ListBucketResult"));
assertThat(testStruct.getStructMembers().get(0).getNameToMarshall(), is("CommonPrefixes"));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class NetNullableVariableUtils_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.Ds3Type in project ds3_autogen by SpectraLogic.
the class BaseRequestGenerator_Test method toNullableArgument_NullableEnumType_Test.
@Test
public void toNullableArgument_NullableEnumType_Test() {
final Ds3Type testType = new Ds3Type("com.spectra.TestType", "", null, createEmptyDs3EnumConstantList());
final ImmutableMap<String, Ds3Type> testTypeMap = ImmutableMap.of(testType.getName(), testType);
final Ds3Param param = new Ds3Param("MyParam", testType.getName(), true);
final NetNullableVariable result = toNullableArgument(param, testTypeMap);
assertThat(result.getNetType(), is("TestType?"));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class Ds3SpecParserImpl_Test method blobApiBean.
@Test
public void blobApiBean() throws IOException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/blobApiBean.xml"));
assertThat(spec.getTypes().size(), is(1));
final Ds3Type blobApiBean = spec.getTypes().get("com.spectralogic.s3.common.platform.domain.BulkObject");
assertThat(blobApiBean, is(notNullValue()));
final ImmutableList<Ds3Element> elements = blobApiBean.getElements();
assertThat(elements.size(), is(7));
assertThat(elements.get(0).getName(), is("InCache"));
assertThat(elements.get(0).getNullable(), is(true));
assertThat(elements.get(1).getName(), is("Latest"));
assertThat(elements.get(1).getNullable(), is(false));
assertThat(elements.get(2).getName(), is("Length"));
assertThat(elements.get(2).getNullable(), is(false));
assertThat(elements.get(3).getName(), is("Name"));
assertThat(elements.get(3).getNullable(), is(true));
assertThat(elements.get(4).getName(), is("Offset"));
assertThat(elements.get(4).getNullable(), is(false));
assertThat(elements.get(5).getName(), is("PhysicalPlacement"));
assertThat(elements.get(5).getNullable(), is(true));
assertThat(elements.get(6).getName(), is("Version"));
assertThat(elements.get(6).getNullable(), is(false));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class CCodeGenerator_Test method testGenerateSingleTypeEnumConstantMatcher.
@Test
public void testGenerateSingleTypeEnumConstantMatcher() throws IOException, TemplateModelException {
final TestFileUtilsImpl fileUtils = new TestFileUtilsImpl();
final Map<String, Object> testMap = new HashMap<>();
final Ds3EnumConstant inProgress = new Ds3EnumConstant("IN_PROGRESS", null);
final Ds3EnumConstant completed = new Ds3EnumConstant("COMPLETED", null);
final Ds3EnumConstant canceled = new Ds3EnumConstant("CANCELED", null);
final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(inProgress, completed, canceled);
final Enum enumEntry = EnumConverter.toEnum(new Ds3Type("JobStatus", null, null, enumConstants));
testMap.put("enumEntry", enumEntry);
final CCodeGenerator codeGenerator = new CCodeGenerator();
codeGenerator.processTemplate(testMap, "source-templates/TypedefEnumMatcher.ftl", fileUtils.getOutputStream());
final ByteArrayOutputStream bstream = (ByteArrayOutputStream) fileUtils.getOutputStream();
final String output = new String(bstream.toByteArray());
final String expectedOutput = "static ds3_job_status _match_ds3_job_status(const ds3_log* log, const xmlChar* text) {" + "\n" + " if (xmlStrcmp(text, (const xmlChar*) \"IN_PROGRESS\") == 0) {" + "\n" + " return DS3_JOB_STATUS_IN_PROGRESS;" + "\n" + " } else if (xmlStrcmp(text, (const xmlChar*) \"COMPLETED\") == 0) {" + "\n" + " return DS3_JOB_STATUS_COMPLETED;" + "\n" + " } else if (xmlStrcmp(text, (const xmlChar*) \"CANCELED\") == 0) {" + "\n" + " return DS3_JOB_STATUS_CANCELED;" + "\n" + " } else {" + "\n" + " ds3_log_message(log, DS3_ERROR, \"ERROR: Unknown value of '%s'. Returning DS3_JOB_STATUS_IN_PROGRESS for safety.\", text);" + "\n" + " return DS3_JOB_STATUS_IN_PROGRESS;" + "\n" + " }" + "\n" + "}" + "\n";
assertThat(expectedOutput, is(output));
}
Aggregations