Search in sources :

Example 26 with Ds3ApiSpec

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"));
}
Also used : Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Test(org.junit.Test)

Example 27 with Ds3ApiSpec

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());
    }
}
Also used : NetCodeGenerator(com.spectralogic.ds3autogen.net.NetCodeGenerator) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) NetCodeGenerator(com.spectralogic.ds3autogen.net.NetCodeGenerator) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)

Example 28 with Ds3ApiSpec

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);
}
Also used : Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)

Example 29 with Ds3ApiSpec

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"));
}
Also used : Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Test(org.junit.Test)

Example 30 with Ds3ApiSpec

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"));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Test(org.junit.Test)

Aggregations

Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)50 Test (org.junit.Test)41 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)37 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)33 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)26 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)24 ByteArrayOutputStream (java.io.ByteArrayOutputStream)22 Enum (com.spectralogic.ds3autogen.c.models.Enum)15 Source (com.spectralogic.ds3autogen.c.models.Source)9 CodeGenerator (com.spectralogic.ds3autogen.api.CodeGenerator)5 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)5 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)5 NameMapper (com.spectralogic.ds3autogen.NameMapper)4 Ds3DocSpecParser (com.spectralogic.ds3autogen.api.Ds3DocSpecParser)4 Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)4 Ds3DocSpecParserImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecParserImpl)4 JavaCodeGenerator (com.spectralogic.ds3autogen.java.JavaCodeGenerator)4 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)2