Search in sources :

Example 11 with Ds3Param

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

the class RequestGeneratorUtil_Test method toWithConstructors_NonNullableParams_Test.

@Test
public void toWithConstructors_NonNullableParams_Test() {
    final ImmutableList<WithConstructor> expected = ImmutableList.of(new WithConstructor("ParamOne", "Type1", "param_one", "paramOne.String()"), new WithConstructor("ParamThree", "int", "param_three", "strconv.Itoa(paramThree)"), new WithConstructor("TypeName", "TypeName", "type", "typeName.String()"));
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("ParamOne", "Type1", false), new Ds3Param("ParamTwo", "void", false), new Ds3Param("ParamThree", "int", false), new Ds3Param("ParamFour", "VOID", false), new Ds3Param("Type", "com.test.TypeName", false));
    final ImmutableList<WithConstructor> result = toWithConstructors(params, false);
    assertThat(result.size(), is(expected.size()));
    expected.forEach(expectedConst -> assertThat(result, hasItem(expectedConst)));
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) WithConstructor(com.spectralogic.ds3autogen.go.models.request.WithConstructor) Test(org.junit.Test)

Example 12 with Ds3Param

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

the class RequestGeneratorUtil_Test method toGoArgument_Test.

@Test
public void toGoArgument_Test() {
    final ImmutableList<Arguments> expectedArgs = ImmutableList.of(new Arguments("", "param1"), new Arguments("*int", "param2"), new Arguments("float64", "param3"), new Arguments("string", "param4"), new Arguments("TestType", "testType"));
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("Param1", "void", false), new Ds3Param("Param2", "java.lang.Integer", true), new Ds3Param("Param3", "double", false), new Ds3Param("Param4", "java.util.UUID", false), new Ds3Param("Type", "com.test.TestType", false));
    for (int i = 0; i < params.size(); i++) {
        final Arguments result = toGoArgument(params.get(i));
        final Arguments expected = expectedArgs.get(i);
        assertThat(result.getName(), is(expected.getName()));
        assertThat(result.getType(), is(expected.getType()));
    }
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Example 13 with Ds3Param

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

the class RequestGeneratorUtil_Test method toWithConstructors_NullableParams_Test.

@Test
public void toWithConstructors_NullableParams_Test() {
    final ImmutableList<WithConstructor> expected = ImmutableList.of(new WithConstructor("ParamOne", "*Type1", "param_one", "paramOne.String()"), new WithConstructor("ParamThree", "*int", "param_three", "strconv.Itoa(*paramThree)"), new WithConstructor("TypeName", "*TypeName", "type", "typeName.String()"));
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("ParamOne", "Type1", true), new Ds3Param("ParamTwo", "void", true), new Ds3Param("ParamThree", "int", true), new Ds3Param("ParamFour", "VOID", true), new Ds3Param("Type", "com.test.TypeName", true));
    final ImmutableList<WithConstructor> result = toWithConstructors(params, true);
    assertThat(result.size(), is(expected.size()));
    expected.forEach(expectedConst -> assertThat(result, hasItem(expectedConst)));
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) WithConstructor(com.spectralogic.ds3autogen.go.models.request.WithConstructor) Test(org.junit.Test)

Example 14 with Ds3Param

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

the class RequestGeneratorUtil_Test method toSimpleVariables_FullList_Test.

@Test
public void toSimpleVariables_FullList_Test() {
    final ImmutableList<SimpleVariable> expected = ImmutableList.of(new SimpleVariable("paramOne"), new SimpleVariable("paramTwo"), new SimpleVariable("paramThree"), new SimpleVariable("typeName"));
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("ParamOne", "string", false), new Ds3Param("ParamTwo", "string", true), new Ds3Param("ParamThree", "string", false), new Ds3Param("Type", "com.test.TypeName", false));
    final ImmutableList<SimpleVariable> result = toSimpleVariables(params);
    assertThat(result.size(), is(expected.size()));
    expected.forEach(expectedVar -> assertThat(result, hasItem(expectedVar)));
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) SimpleVariable(com.spectralogic.ds3autogen.go.models.request.SimpleVariable) Test(org.junit.Test)

Example 15 with Ds3Param

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

the class RequestGeneratorUtil_Test method toGoArgumentsList_FullList_Test.

@Test
public void toGoArgumentsList_FullList_Test() {
    final ImmutableList<String> expectedTypes = ImmutableList.of("", "*int", "float64", "string");
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("Param1", "void", false), new Ds3Param("Param2", "java.lang.Integer", true), new Ds3Param("Param3", "double", false), new Ds3Param("Param4", "java.util.UUID", false));
    final ImmutableList<Arguments> result = toGoArgumentsList(params);
    assertThat(result.size(), is(4));
    for (int i = 0; i < result.size(); i++) {
        assertThat(result.get(i).getType(), is(expectedTypes.get(i)));
    }
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Aggregations

Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)39 Test (org.junit.Test)37 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)10 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)8 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)8 NetNullableVariable (com.spectralogic.ds3autogen.net.model.common.NetNullableVariable)8 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)5 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)5 Ds3ModelPartialDataFixture.createEmptyDs3Request (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Request)5 ImmutableList (com.google.common.collect.ImmutableList)3 Parameter (com.spectralogic.ds3autogen.c.models.Parameter)3 SimpleVariable (com.spectralogic.ds3autogen.go.models.request.SimpleVariable)3 WithConstructor (com.spectralogic.ds3autogen.go.models.request.WithConstructor)3 RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)3 Request (com.spectralogic.ds3autogen.c.models.Request)2 Variable (com.spectralogic.ds3autogen.go.models.request.Variable)2 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 HashMap (java.util.HashMap)2 Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)1