Search in sources :

Example 6 with Ds3Type

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.

the class BaseTypeParserSetGenerator_Test method getTypeParserGenerator_JobsList_Test.

@Test
public void getTypeParserGenerator_JobsList_Test() {
    final Ds3Type jobsList = createDs3TypeTestData("com.spectralogic.s3.server.domain.JobList");
    final TypeParserGenerator<?> result = getTypeParserGenerator(jobsList);
    assertThat(result, instanceOf(JobListParserGenerator.class));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) JobListParserGenerator(com.spectralogic.ds3autogen.net.generators.parsers.type.JobListParserGenerator) Test(org.junit.Test)

Example 7 with Ds3Type

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.

the class NetCodeGenerator method generateResponseAndParser.

/**
     * Generates the .net code for the response handler and parser described in the Ds3Request
     */
private void generateResponseAndParser(final Ds3Request ds3Request) throws IOException, TemplateException {
    if (!ResponsePayloadUtil.hasResponsePayload(ds3Request.getDs3ResponseCodes())) {
        //Check if the request is an exception for generating response and parser files
        if (hasResponseHandlerAndParser(ds3Request)) {
            generateResponse(ds3Request, null);
            generateResponseParser(ds3Request, null);
        }
        //There is no payload for this Ds3Request, so do not generate any response handling code
        return;
    }
    final String responsePayloadType = getResponsePayloadType(ds3Request.getDs3ResponseCodes());
    if ((isEmpty(responsePayloadType) || !responsePayloadType.equalsIgnoreCase("java.lang.String")) && isEmpty(spec.getTypes())) {
        LOG.error("Cannot generate response because type map is empty");
        return;
    }
    if (responsePayloadType == null) {
        throw new IllegalArgumentException("Cannot generate a response because there are no non-error payloads: " + ds3Request.getName());
    }
    generateResponse(ds3Request, responsePayloadType);
    if (responsePayloadType.equalsIgnoreCase("java.lang.String")) {
        generateResponseParser(ds3Request, null);
    } else {
        final Ds3Type ds3TypePayload = spec.getTypes().get(responsePayloadType);
        generateResponseParser(ds3Request, ds3TypePayload);
    }
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)

Example 8 with Ds3Type

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.

the class ChecksumTypeGenerator_Test method getAllImports_Test.

@Test
public void getAllImports_Test() {
    final ImmutableList<Ds3Element> ds3Elements = ImmutableList.of(new Ds3Element("ElementName1", "com.spectralogic.test.ElementType1", "ElementComponentType1", false), new Ds3Element("ElementName2", "ElementType2", "com.spectralogic.test.ElementComponentType2", false), new Ds3Element("ElementName3", "ElementType3", null, false));
    final Ds3Type ds3Type = new Ds3Type("TypeName", null, ds3Elements, null);
    final ImmutableList<String> result = generator.getAllImports(ds3Type);
    assertThat(result.size(), is(0));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 9 with Ds3Type

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.

the class CommonPrefixGenerator_Test method getAllImports_Test.

@Test
public void getAllImports_Test() {
    final ImmutableList<Ds3Element> ds3Elements = ImmutableList.of(new Ds3Element("ElementName1", "com.spectralogic.test.ElementType1", "ElementComponentType1", false), new Ds3Element("ElementName2", "ElementType2", "com.spectralogic.test.ElementComponentType2", false), new Ds3Element("ElementName3", "ElementType3", null, false));
    final Ds3Type ds3Type = new Ds3Type("TypeName", null, ds3Elements, null);
    final ImmutableList<String> result = generator.getAllImports(ds3Type);
    assertThat(result.size(), is(4));
    assertThat(result, hasItem("java.util.List"));
    assertThat(result, hasItem("java.util.ArrayList"));
    assertThat(result, hasItem("com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper"));
    assertThat(result, hasItem("com.spectralogic.ds3client.models.common.CommonPrefixes"));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 10 with Ds3Type

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.

the class BaseTypeGenerator_Test method toNameToMarshal_EmptyValue_Test.

@Test
public void toNameToMarshal_EmptyValue_Test() {
    final Ds3Type type = new Ds3Type("Name", "", null, null);
    final String result = generator.toNameToMarshal(type);
    assertThat(result, is(""));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Test(org.junit.Test)

Aggregations

Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)44 Test (org.junit.Test)37 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)22 Ds3EnumConstant (com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant)9 Enum (com.spectralogic.ds3autogen.c.models.Enum)6 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)5 Ds3ModelPartialDataFixture.createEmptyDs3Type (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)4 Struct (com.spectralogic.ds3autogen.c.models.Struct)4 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 ImmutableList (com.google.common.collect.ImmutableList)3 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)2 NameMapper (com.spectralogic.ds3autogen.NameMapper)2 Ds3DocSpecParser (com.spectralogic.ds3autogen.api.Ds3DocSpecParser)2 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)2 SourceConverter (com.spectralogic.ds3autogen.c.converters.SourceConverter)2 StructConverter (com.spectralogic.ds3autogen.c.converters.StructConverter)2 EnumHelper (com.spectralogic.ds3autogen.c.helpers.EnumHelper)2