use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec in project ds3_autogen by SpectraLogic.
the class Ds3SpecParserImpl_Test method twoRequestHandlersAndOneType.
@Test
public void twoRequestHandlersAndOneType() throws IOException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/twoRequestHandlersAndOneType.xml"));
assertThat(spec, is(notNullValue()));
assertThat(spec.getTypes(), is(notNullValue()));
assertThat(spec.getTypes().size(), is(1));
assertThat(spec.getTypes().containsKey("com.spectralogic.s3.common.dao.domain.ds3.Priority"), is(true));
final Ds3Type ds3Type = spec.getTypes().get("com.spectralogic.s3.common.dao.domain.ds3.Priority");
assertThat(ds3Type, is(notNullValue()));
assertThat(ds3Type.getName(), is("com.spectralogic.s3.common.dao.domain.ds3.Priority"));
assertThat(ds3Type.getElements(), is(notNullValue()));
assertThat(ds3Type.getElements().size(), is(1));
assertThat(ds3Type.getElements().get(0).getName(), is("SpecifiableByUser"));
assertThat(ds3Type.getElements().get(0).getType(), is("boolean"));
assertThat(ds3Type.getElements().get(0).getComponentType(), is(nullValue()));
assertThat(ds3Type.getElements().get(0).getDs3Annotations().size(), is(0));
assertThat(ds3Type.getEnumConstants(), is(notNullValue()));
assertThat(ds3Type.getEnumConstants().size(), is(6));
assertThat(ds3Type.getEnumConstants().get(0).getName(), is("CRITICAL"));
assertThat(ds3Type.getEnumConstants().get(0).getDs3Properties(), is(notNullValue()));
assertThat(ds3Type.getEnumConstants().get(0).getDs3Properties().get(0).getName(), is("SpecifiableByUser"));
assertThat(ds3Type.getEnumConstants().get(0).getDs3Properties().get(0).getValue(), is("false"));
assertThat(ds3Type.getEnumConstants().get(0).getDs3Properties().get(0).getValueType(), is("boolean"));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec in project ds3_autogen by SpectraLogic.
the class TestGenerateCode method generateCode.
/**
* Generates the .net code associated with an input file. THis captures the
* Request, Client and IDsClient code. This allows for a Ds3DocSpec parser to
* be specified
*/
public void generateCode(final FileUtils fileUtils, final String inputFileName, final Ds3DocSpec docSpec) throws IOException, TemplateModelException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(TestGenerateCode.class.getResourceAsStream(inputFileName));
final CodeGenerator codeGenerator = new NetCodeGenerator();
codeGenerator.generate(spec, fileUtils, Paths.get("."), docSpec);
requestCode = new String(requestOutputStream.toByteArray());
responseCode = new String(responseOutputStream.toByteArray());
clientCode = new String(clientOutputStream.toByteArray());
idsClientCode = new String(idsClientOutputStream.toByteArray());
typeParser = new String(typeParserOutputStream.toByteArray());
parserCode = new String(parserOutputStream.toByteArray());
if (responseTypeOutputStream != null) {
typeCode = new String(responseTypeOutputStream.toByteArray());
}
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec in project ds3_autogen by SpectraLogic.
the class Ds3SpecParserImpl method toSpec.
private static Ds3ApiSpec toSpec(final RawSpec contract, final boolean generateInternal) throws IOException {
final NameMapper nameMapper = new NameMapper();
final Ds3ApiSpec ds3ApiSpec = new Ds3ApiSpec(Ds3SpecConverter.convertRequests(contract.getContract().getDs3Requests(), nameMapper), Ds3SpecConverter.convertTypes(contract.getContract().getDs3Types(), nameMapper));
return Ds3SpecNormalizer.convertSpec(ds3ApiSpec, generateInternal);
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec in project ds3_autogen by SpectraLogic.
the class Ds3SpecParserImpl_Test method SingleRequestHandler.
@Test
public void SingleRequestHandler() throws IOException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/singleRequestHandler.xml"));
assertThat(spec, is(notNullValue()));
assertThat(spec.getRequests().size(), is(1));
final Ds3Request ds3Request = spec.getRequests().get(0);
assertThat(ds3Request.getName(), is("com.spectralogic.s3.server.handler.reqhandler.amazons3.GetObjectRequest"));
assertThat(ds3Request.getHttpVerb(), is(HttpVerb.GET));
assertThat(ds3Request.getClassification(), is(Classification.amazons3));
assertThat(ds3Request.getBucketRequirement(), is(Requirement.REQUIRED));
assertThat(ds3Request.getObjectRequirement(), is(Requirement.REQUIRED));
assertThat(ds3Request.getAction(), is(nullValue()));
assertThat(ds3Request.getResource(), is(nullValue()));
assertThat(ds3Request.getResourceType(), is(nullValue()));
assertThat(ds3Request.getOperation(), is(nullValue()));
assertThat(ds3Request.getDs3ResponseCodes().size(), is(1));
assertThat(ds3Request.getDs3ResponseCodes().get(0).getCode(), is(200));
assertThat(ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().size(), is(1));
assertThat(ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().get(0).getType(), is("java.lang.String"));
assertThat(ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().get(0).getComponentType(), is(nullValue()));
assertThat(ds3Request.getOptionalQueryParams().size(), is(0));
assertThat(ds3Request.getRequiredQueryParams().size(), is(1));
assertThat(ds3Request.getRequiredQueryParams().get(0).getName(), is("Id"));
assertThat(ds3Request.getRequiredQueryParams().get(0).getType(), is("java.util.UUID"));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec in project ds3_autogen by SpectraLogic.
the class NameConverter_Test method renameRequests_FullList_Test.
@Test
public void renameRequests_FullList_Test() {
final Ds3ApiSpec spec = new Ds3ApiSpec(ImmutableList.of(new Ds3Request("com.spectralogic.test.MyTestOneRequestHandler", null, Classification.spectrads3, null, null, null, null, null, null, false, null, null, null), new Ds3Request("com.spectralogic.test.MyTestTwoRequestHandler", null, Classification.amazons3, null, null, null, null, null, null, false, null, null, null)), null);
final Ds3ApiSpec result = renameRequests(spec);
assertThat(result.getRequests().size(), is(2));
assertThat(result.getRequests().get(0).getName(), is("com.spectralogic.test.MyTestOneSpectraS3Request"));
assertThat(result.getRequests().get(1).getName(), is("com.spectralogic.test.MyTestTwoRequest"));
}
Aggregations