Search in sources :

Example 11 with Element

use of com.spectralogic.ds3autogen.java.models.Element in project ds3_autogen by SpectraLogic.

the class CommonPrefixGenerator_Test method toElementList_List_Test.

@Test
public void toElementList_List_Test() {
    final ImmutableList<Ds3Element> elements = ImmutableList.of(new Ds3Element("CommonPrefixes", "array", "java.lang.String", false), new Ds3Element("CreationDate", "java.util.Date", null, false));
    final ImmutableList<Element> result = generator.toElementList(elements);
    assertThat(result.size(), is(2));
    assertThat(result.get(0).getName(), is("CommonPrefixes"));
    assertThat(result.get(0).getType(), is("array"));
    assertThat(result.get(0).getComponentType(), is("CommonPrefixes"));
    assertThat(result.get(1).getName(), is("CreationDate"));
    assertThat(result.get(1).getType(), is("java.util.Date"));
    assertThat(result.get(1).getComponentType(), is(nullValue()));
}
Also used : Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Element(com.spectralogic.ds3autogen.java.models.Element) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Test(org.junit.Test)

Example 12 with Element

use of com.spectralogic.ds3autogen.java.models.Element in project ds3_autogen by SpectraLogic.

the class JavaHelper_Test method sortModelConstructorArgs_FullList_Test.

@Test
public void sortModelConstructorArgs_FullList_Test() {
    final ImmutableList<Element> expectedResult = ImmutableList.of(new Element("Elmt1", "Type1", null), new Element("Elmt2", "Type2", null), new Element("Elmt3", "array", "Type3"));
    final ImmutableList<Element> elements = ImmutableList.of(new Element("Elmt2", "Type2", null), new Element("Elmt3", "array", "Type3"), new Element("Elmt1", "Type1", null));
    final ImmutableList<Element> result = sortModelConstructorArgs(elements);
    for (int i = 0; i < elements.size(); i++) {
        assertTrue(result.get(i).getName().equals(expectedResult.get(i).getName()));
    }
    final ImmutableList<Element> emptyResult = sortModelConstructorArgs(null);
    assertTrue(emptyResult.isEmpty());
}
Also used : Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Example 13 with Element

use of com.spectralogic.ds3autogen.java.models.Element in project ds3_autogen by SpectraLogic.

the class JavaHelper_Test method getModelVariable_ArrayComponentType_Test.

@Test
public void getModelVariable_ArrayComponentType_Test() {
    final String expectedResult = "    @JsonProperty(\"XmlName\")\n" + "    @JacksonXmlElementWrapper(useWrapping = false)\n" + "    private List<BlobApiBean> testName = new ArrayList<>();";
    final Element element = new Element("testName", "xmlName", false, false, "array", "com.spectralogic.s3.common.platform.domain.BlobApiBean");
    final String result = getModelVariable(element);
    assertThat(result, is(expectedResult));
}
Also used : Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Example 14 with Element

use of com.spectralogic.ds3autogen.java.models.Element in project ds3_autogen by SpectraLogic.

the class JavaHelper_Test method getModelVariable_ComponentType_Wrapper_Test.

@Test
public void getModelVariable_ComponentType_Wrapper_Test() {
    final String expectedResult = "    @JsonProperty(\"TestName\")\n" + "    @JacksonXmlElementWrapper(useWrapping = true)\n" + "    private List<BlobApiBean> testName = new ArrayList<>();";
    final Element element = new Element("testName", "xmlName", false, true, "array", "com.spectralogic.s3.common.platform.domain.BlobApiBean");
    final String result = getModelVariable(element);
    assertThat(result, is(expectedResult));
}
Also used : Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Example 15 with Element

use of com.spectralogic.ds3autogen.java.models.Element in project ds3_autogen by SpectraLogic.

the class JavaHelper_Test method getModelConstructorArgs_FullList_Test.

@Test
public void getModelConstructorArgs_FullList_Test() {
    final String expectedResult = "final Type1 elmt1, final Type2 elmt2, final List<Type3> elmt3";
    final ImmutableList<Element> elements = ImmutableList.of(new Element("Elmt2", "Type2", null), new Element("Elmt1", "Type1", null), new Element("Elmt3", "array", "Type3"));
    final String result = getModelConstructorArgs(elements);
    assertThat(result, is(expectedResult));
    final String emptyResult = getModelConstructorArgs(null);
    assertThat(emptyResult, is(""));
}
Also used : Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Aggregations

Element (com.spectralogic.ds3autogen.java.models.Element)19 Test (org.junit.Test)18 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)6 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)4 TestGeneratedModelCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode)4 Ds3Annotation (com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation)2 Ds3AnnotationElement (com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement)2 ImmutableList (com.google.common.collect.ImmutableList)1