Search in sources :

Example 41 with Ds3Element

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

the class Ds3TypeClassificationUtil_Test method containsElement_Test.

@Test
public void containsElement_Test() {
    final ImmutableList<Ds3Element> elements = ImmutableList.of(new Ds3Element("Code", "java.lang.String", null, true), new Ds3Element("HttpErrorCode", "int", null, false));
    final Ds3Type type = createDs3TypeTestData("TestType", elements);
    assertTrue(containsElement(type, "Code"));
    assertTrue(containsElement(type, "HttpErrorCode"));
    assertFalse(containsElement(type, "Resource"));
    assertFalse(containsElement(type, "ResourceId"));
}
Also used : Ds3ModelPartialDataFixture.createEmptyDs3Type(com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 42 with Ds3Element

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Element 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 43 with Ds3Element

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

the class Ds3TypeClassificationUtil_Test method isCommonPrefixesType_Test.

@Test
public void isCommonPrefixesType_Test() {
    final ImmutableList<Ds3Element> elements = ImmutableList.of(new Ds3Element("CommonPrefixes", "array", "java.lang.String", true));
    final Ds3Type type = createDs3TypeTestData("TestType", elements);
    assertTrue(isCommonPrefixesType(type));
}
Also used : Ds3ModelPartialDataFixture.createEmptyDs3Type(com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 44 with Ds3Element

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

the class Ds3ElementUtil_Test method getXmlTagName_Test.

@Test
public void getXmlTagName_Test() {
    final ImmutableList<Ds3Annotation> annotations = ImmutableList.of(createSimpleNameAnnotation(), createNonCustomMarshaledNameAnnotation(), createCustomMarshaledNameAnnotation());
    final Ds3Element element = new Ds3Element("ElementName", "Type", "ComponentType", annotations, false);
    final String result = getXmlTagName(element);
    assertThat(result, CoreMatchers.is("Error"));
}
Also used : Ds3Annotation(com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 45 with Ds3Element

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

the class StructHelper_Test method testGenerateStructMembers.

@Test
public void testGenerateStructMembers() throws ParseException {
    final Ds3Element testElement1 = new Ds3Element("boolElement", "boolean", null, false);
    final Ds3Element testElement2 = new Ds3Element("beanElement", "com.spectralogic.s3.server.domain.UserApiBean", null, false);
    final ImmutableList<Ds3Element> elementsList = ImmutableList.of(testElement1, testElement2);
    final Ds3Type ds3Type = new Ds3Type("testDs3Type", elementsList);
    final ImmutableSet.Builder<String> enumNames = ImmutableSet.builder();
    final Struct testStruct = StructConverter.toStruct(ds3Type, enumNames.build(), ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of());
    final String output = StructMemberHelper.generateStructMembers(testStruct.getStructMembers());
    assertTrue(output.contains("ds3_bool bool_element;"));
    assertTrue(output.contains("ds3_user_api_bean_response* bean_element;"));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Aggregations

Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)54 Test (org.junit.Test)48 Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)22 C_Type (com.spectralogic.ds3autogen.c.models.C_Type)10 Ds3Annotation (com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation)9 Element (com.spectralogic.ds3autogen.java.models.Element)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 Ds3AnnotationElement (com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement)5 ImmutableList (com.google.common.collect.ImmutableList)4 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)4 Struct (com.spectralogic.ds3autogen.c.models.Struct)4 NetNullableVariable (com.spectralogic.ds3autogen.net.model.common.NetNullableVariable)4 Ds3ModelPartialDataFixture.createEmptyDs3Type (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Type)4 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)3 Ds3EnumConstant (com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant)3 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)2 NameMapper (com.spectralogic.ds3autogen.NameMapper)2 Ds3DocSpecParser (com.spectralogic.ds3autogen.api.Ds3DocSpecParser)2