Search in sources :

Example 46 with Ds3ApiSpec

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

the class CCodeGenerator_Test method testEmbeddedTypesSet.

@Test
public void testEmbeddedTypesSet() {
    final Ds3Type type1 = new Ds3Type("Ds3Bucket", ImmutableList.of(new Ds3Element("ChecksumType", "Ds3ChecksumType", null, true), new Ds3Element("Size", "Ds3Size", null, true)));
    final Ds3Type type2 = new Ds3Type("Ds3Object", ImmutableList.of(new Ds3Element("Name", "java.lang.String", null, true), new Ds3Element("Size", "Ds3Size", null, true)));
    final Ds3ApiSpec embeddedTypesSet = new Ds3ApiSpec(ImmutableList.of(), ImmutableMap.of(type1.getName(), type1, type2.getName(), type2));
    final ImmutableSet<String> embeddedTypes = CCodeGenerator.getEmbeddedTypes(embeddedTypesSet, ImmutableSet.of());
    assertEquals(embeddedTypes.size(), 2);
    assertTrue(embeddedTypes.contains("ds3_size_response"));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Test(org.junit.Test)

Example 47 with Ds3ApiSpec

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

the class CCodeGenerator_Test method testEnumTypesContainsTargetReadPreferenceType.

@Test
public void testEnumTypesContainsTargetReadPreferenceType() 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);
    assertTrue(enumNames.contains("ds3_target_read_preference_type"));
}
Also used : Enum(com.spectralogic.ds3autogen.c.models.Enum) Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Test(org.junit.Test)

Example 48 with Ds3ApiSpec

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

the class TestGeneratedComponentResponseCode method generateCode.

@Override
public void generateCode(final FileUtils fileUtils, final String inputFileName) throws IOException, TemplateModelException {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    final Ds3ApiSpec spec = parser.getSpec(TestGeneratedCode.class.getResourceAsStream(inputFileName));
    final CodeGenerator codeGenerator = new JavaCodeGenerator();
    codeGenerator.generate(spec, fileUtils, Paths.get("."), new Ds3DocSpecEmptyImpl());
    requestGeneratedCode = new String(requestOutputStream.toByteArray());
    responseGeneratedCode = new String(responseOutputStream.toByteArray());
    responseParserGeneratedCode = new String(responseParserOutputStream.toByteArray());
    encapsulatingTypeGeneratedCode = new String(encapsulatingTypeOutputStream.toByteArray());
    ds3ClientGeneratedCode = new String(ds3ClientOutputStream.toByteArray());
    ds3ClientImplGeneratedCode = new String(ds3ClientImplOutputStream.toByteArray());
}
Also used : Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) JavaCodeGenerator(com.spectralogic.ds3autogen.java.JavaCodeGenerator) JavaCodeGenerator(com.spectralogic.ds3autogen.java.JavaCodeGenerator) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)

Example 49 with Ds3ApiSpec

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

the class TestGeneratedModelCode method generateCode.

public void generateCode(final FileUtils fileUtils, final String inputFileName) throws IOException, TemplateModelException {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    final Ds3ApiSpec spec = parser.getSpec(TestGeneratedModelCode.class.getResourceAsStream(inputFileName));
    final CodeGenerator codeGenerator = new JavaCodeGenerator();
    codeGenerator.generate(spec, fileUtils, Paths.get("."), new Ds3DocSpecEmptyImpl());
    modelGeneratedCode = new String(modelOutputStream.toByteArray());
}
Also used : Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) JavaCodeGenerator(com.spectralogic.ds3autogen.java.JavaCodeGenerator) JavaCodeGenerator(com.spectralogic.ds3autogen.java.JavaCodeGenerator) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)

Example 50 with Ds3ApiSpec

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

the class TestGeneratedCode method generateCode.

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(TestGeneratedCode.class.getResourceAsStream(inputFileName));
    final CodeGenerator codeGenerator = new JavaCodeGenerator();
    codeGenerator.generate(spec, fileUtils, Paths.get("."), docSpec);
    requestGeneratedCode = new String(requestOutputStream.toByteArray());
    responseGeneratedCode = new String(responseOutputStream.toByteArray());
    responseParserGeneratedCode = new String(responseParserOutputStream.toByteArray());
    ds3ClientGeneratedCode = new String(ds3ClientOutputStream.toByteArray());
    ds3ClientImplGeneratedCode = new String(ds3ClientImplOutputStream.toByteArray());
}
Also used : Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) JavaCodeGenerator(com.spectralogic.ds3autogen.java.JavaCodeGenerator) JavaCodeGenerator(com.spectralogic.ds3autogen.java.JavaCodeGenerator) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)

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