use of com.spectralogic.ds3autogen.api.Ds3SpecParser in project ds3_autogen by SpectraLogic.
the class Ds3SpecParserImpl_Test method twoRequestHandlersAndTwoTypes.
@Test
public void twoRequestHandlersAndTwoTypes() throws IOException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/twoRequestHandlersAndTwoTypes.xml"));
assertThat(spec, is(notNullValue()));
assertThat(spec.getTypes(), is(notNullValue()));
assertThat(spec.getTypes().size(), is(2));
assertThat(spec.getTypes().containsKey("com.spectralogic.s3.common.dao.domain.ds3.Priority"), is(true));
assertThat(spec.getTypes().containsKey("com.spectralogic.s3.common.dao.domain.tape.DetailedTapeFailure"), is(true));
assertThat(spec.getTypes().get("com.spectralogic.s3.common.dao.domain.ds3.Priority"), is(notNullValue()));
assertThat(spec.getTypes().get("com.spectralogic.s3.common.dao.domain.tape.DetailedTapeFailure"), is(notNullValue()));
}
use of com.spectralogic.ds3autogen.api.Ds3SpecParser in project ds3_autogen by SpectraLogic.
the class Ds3SpecParserImpl_Test method fullXml.
@Test
public void fullXml() throws IOException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/fullXml.xml"));
assertThat(spec, is(notNullValue()));
assertThat(spec.getRequests(), is(notNullValue()));
assertThat(spec.getTypes(), is(notNullValue()));
}
use of com.spectralogic.ds3autogen.api.Ds3SpecParser in project ds3_autogen by SpectraLogic.
the class GoTestCodeUtil method generateCode.
/**
* Generates the Go code associated with an input file containing a contract.
*/
public void generateCode(final FileUtils fileUtils, final String inputFileName) throws IOException, TemplateModelException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(GoTestCodeUtil.class.getResourceAsStream(inputFileName));
final CodeGenerator codeGenerator = new GoCodeGenerator();
final Ds3DocSpec docSpec = new Ds3DocSpecEmptyImpl();
// Generate the Go Code from the input file
codeGenerator.generate(spec, fileUtils, Paths.get("."), docSpec);
// Capture the generated command files
requestCode = new String(requestOutputStream.toByteArray());
responseCode = new String(responseOutputStream.toByteArray());
// Capture the generate response payload type if one exists
if (typeOutputStream != null) {
typeCode = new String(typeOutputStream.toByteArray());
}
// Capture the generated client files and associate them with the HttpVerb of
// the commands contained within the file
final ImmutableMap.Builder<HttpVerb, String> builder = ImmutableMap.builder();
for (final Map.Entry<HttpVerb, ByteArrayOutputStream> entry : clientOutputStreams.entrySet()) {
builder.put(entry.getKey(), new String(entry.getValue().toByteArray()));
}
clientCode = builder.build();
}
use of com.spectralogic.ds3autogen.api.Ds3SpecParser in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method wholeXmlDoc.
@Test
public void wholeXmlDoc() throws IOException, TemplateModelException {
final FileUtils fileUtils = new TestFileUtilsImpl();
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(JavaFunctionalTests.class.getResourceAsStream("/input/fullXml.xml"));
final CodeGenerator codeGenerator = new JavaCodeGenerator();
codeGenerator.generate(spec, fileUtils, Paths.get("."), new Ds3DocSpecEmptyImpl());
}
use of com.spectralogic.ds3autogen.api.Ds3SpecParser in project ds3_autogen by SpectraLogic.
the class CCodeGenerator_Test method testStuctsContainsJobCreationFailedNotificationPayload.
@Test
public void testStuctsContainsJobCreationFailedNotificationPayload() 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);
final ImmutableSet<String> arrayMemberTypes = CCodeGenerator.getArrayMemberTypes(spec, enumNames);
final ImmutableSet<String> embeddedTypes = CCodeGenerator.getEmbeddedTypes(spec, enumNames);
final ImmutableList<Request> allRequests = CCodeGenerator.getAllRequests(spec, new Ds3DocSpecEmptyImpl());
final ImmutableSet<String> responseTypes = RequestHelper.getResponseTypes(allRequests);
final ImmutableSet<String> paginatedTypes = CCodeGenerator.getPaginatedTypes(spec);
final ImmutableList<Struct> allStructs = CCodeGenerator.getAllStructs(spec, enumNames, responseTypes, embeddedTypes, arrayMemberTypes, paginatedTypes);
assertTrue(allStructs.stream().map(Struct::getName).anyMatch(name -> name.equals("ds3_job_creation_failed_notification_payload_response")));
}
Aggregations