Search in sources :

Example 36 with Ds3SpecParser

use of com.spectralogic.ds3autogen.api.Ds3SpecParser 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 37 with Ds3SpecParser

use of com.spectralogic.ds3autogen.api.Ds3SpecParser 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)

Aggregations

Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)37 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)37 Test (org.junit.Test)33 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)29 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)24 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 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)5 NameMapper (com.spectralogic.ds3autogen.NameMapper)4 Ds3DocSpecParser (com.spectralogic.ds3autogen.api.Ds3DocSpecParser)4 Ds3DocSpecParserImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecParserImpl)4 Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)2 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)2 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)2 Request (com.spectralogic.ds3autogen.c.models.Request)2