Search in sources :

Example 6 with TypeElementList

use of com.spectralogic.ds3autogen.python.model.type.TypeElementList in project ds3_autogen by SpectraLogic.

the class PythonFunctionalTests method simpleType.

@Test
public void simpleType() throws TemplateModelException, IOException {
    final String modelDescriptorName = "TestElementsType";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/types/simpleType.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.MODEL_PARSERS);
    assertTrue(hasContent(ds3Code));
    final ImmutableList<TypeContent> modelContents = ImmutableList.of(new TypeAttribute("InCache"), new TypeElement("MyBucket", "BucketDetails"), new TypeElement("ByteOffset", "None"), new TypeElementList("MyBucketList", "None", "BucketDetails"), new TypeElementList("Pool", "Pools", "None"));
    hasModelDescriptor(modelDescriptorName, modelContents, ds3Code);
}
Also used : TypeAttribute(com.spectralogic.ds3autogen.python.model.type.TypeAttribute) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TypeElement(com.spectralogic.ds3autogen.python.model.type.TypeElement) TypeContent(com.spectralogic.ds3autogen.python.model.type.TypeContent) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Example 7 with TypeElementList

use of com.spectralogic.ds3autogen.python.model.type.TypeElementList in project ds3_autogen by SpectraLogic.

the class PythonFunctionalTests method bucketObjectsApiBean.

@Test
public void bucketObjectsApiBean() throws TemplateModelException, IOException {
    final String modelDescriptorName = "ListBucketResult";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/types/bucketObjectsApiBean.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.MODEL_PARSERS);
    assertTrue(hasContent(ds3Code));
    final ImmutableList<TypeContent> modelContents = ImmutableList.of(new TypeElement("CreationDate", "None"), new TypeElement("Delimiter", "None"), new TypeElement("Marker", "None"), new TypeElement("MaxKeys", "None"), new TypeElement("Name", "None"), new TypeElement("NextMarker", "None"), new TypeElement("Prefix", "None"), new TypeElement("IsTruncated", "None"), new TypeElementList("CommonPrefixes", "None", "CommonPrefixes"), new TypeElementList("Contents", "None", "Contents"));
    hasModelDescriptor(modelDescriptorName, modelContents, ds3Code);
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TypeElement(com.spectralogic.ds3autogen.python.model.type.TypeElement) TypeContent(com.spectralogic.ds3autogen.python.model.type.TypeContent) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Example 8 with TypeElementList

use of com.spectralogic.ds3autogen.python.model.type.TypeElementList in project ds3_autogen by SpectraLogic.

the class BaseTypeGenerator_Test method toElementList_Jobs_Test.

@Test
public void toElementList_Jobs_Test() {
    final ImmutableList<Ds3AnnotationElement> annotations = ImmutableList.of(new Ds3AnnotationElement("CollectionValue", "Jobs", "java.lang.String"), new Ds3AnnotationElement("CollectionValueRenderingMode", "SINGLE_BLOCK_FOR_ALL_ELEMENTS", "com.spectralogic.util.marshal.CustomMarshaledName$CollectionNameRenderingMode"), new Ds3AnnotationElement("Value", "Job", "java.lang.String"));
    final Ds3Element jobs = new Ds3Element("Jobs", "array", "com.spectralogic.s3.server.domain.Job", ImmutableList.of(new Ds3Annotation("com.spectralogic.util.marshal.CustomMarshaledName", annotations)), false);
    final Ds3Type jobApiBean = createDs3TypeTestData("com.spectralogic.s3.server.domain.Job");
    final TypeElementList result = toElementList(jobs, ImmutableMap.of(jobApiBean.getName(), jobApiBean));
    assertThat(result.toPythonCode(), is("('Job', None, Job())"));
}
Also used : Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3AnnotationElement(com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Test(org.junit.Test)

Example 9 with TypeElementList

use of com.spectralogic.ds3autogen.python.model.type.TypeElementList in project ds3_autogen by SpectraLogic.

the class BaseTypeGenerator_Test method toElementList_Test.

@Test
public void toElementList_Test() {
    final TypeElementList result = toElementList(createListDs3Element(), createTestTypeMap());
    assertThat(result.toPythonCode(), is("('ListElement', None, ListType())"));
}
Also used : TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Example 10 with TypeElementList

use of com.spectralogic.ds3autogen.python.model.type.TypeElementList in project ds3_autogen by SpectraLogic.

the class BaseTypeGenerator_Test method toElementList_EncapsulatedList_Test.

@Test
public void toElementList_EncapsulatedList_Test() {
    final TypeElementList result = toElementList(createEncapsulatedListDs3Element(), createTestTypeMap());
    assertThat(result.toPythonCode(), is("('ListType', 'ListTypes', ListType())"));
}
Also used : TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Aggregations

TypeElementList (com.spectralogic.ds3autogen.python.model.type.TypeElementList)11 Test (org.junit.Test)11 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)5 TypeContent (com.spectralogic.ds3autogen.python.model.type.TypeContent)5 TestPythonGeneratedCode (com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode)5 TypeElement (com.spectralogic.ds3autogen.python.model.type.TypeElement)3 Ds3Annotation (com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation)2 Ds3AnnotationElement (com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement)2 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)2 Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)1 TypeAttribute (com.spectralogic.ds3autogen.python.model.type.TypeAttribute)1