Search in sources :

Example 31 with Ds3Param

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

the class BaseRequestGenerator_Test method toNullableArgument_NullableSpectraType_Test.

@Test
public void toNullableArgument_NullableSpectraType_Test() {
    final Ds3Param param = new Ds3Param("MyParam", "com.spectra.TestType", true);
    final NetNullableVariable result = toNullableArgument(param, ImmutableMap.of());
    assertThat(result.getNetType(), is("TestType"));
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) NetNullableVariable(com.spectralogic.ds3autogen.net.model.common.NetNullableVariable) Test(org.junit.Test)

Example 32 with Ds3Param

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

the class RequestGeneratorUtil_Test method removeVoidParams_FullList_Test.

@Test
public void removeVoidParams_FullList_Test() {
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("Param1", "Type1", false), new Ds3Param("Param2", "void", false), new Ds3Param("Param3", "int", false), new Ds3Param("Param4", "VOID", false));
    final ImmutableList<Ds3Param> result = removeVoidDs3Params(params);
    assertThat(result.size(), is(2));
    result.forEach(param -> assertThat(param.getType(), not("void")));
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) Test(org.junit.Test)

Example 33 with Ds3Param

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

the class RequestGeneratorUtil_Test method toQueryParamVar_Test.

@Test
public void toQueryParamVar_Test() {
    final ImmutableList<Variable> expected = ImmutableList.of(new Variable("param_one", "strconv.Itoa(paramOne)"), new Variable("param_two", "strconv.FormatFloat(paramTwo, 'f', -1, 64)"), new Variable("param_three", "paramThree"), new Variable("param_four", "\"\""));
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("ParamOne", "int", false), new Ds3Param("ParamTwo", "float64", false), new Ds3Param("ParamThree", "string", false), new Ds3Param("ParamFour", "void", false));
    assertThat(expected.size(), is(params.size()));
    for (int i = 0; i < params.size(); i++) {
        final Variable result = toQueryParamVar(params.get(i));
        assertThat(result, is(expected.get(i)));
    }
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) Variable(com.spectralogic.ds3autogen.go.models.request.Variable) SimpleVariable(com.spectralogic.ds3autogen.go.models.request.SimpleVariable) Test(org.junit.Test)

Example 34 with Ds3Param

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

the class RequestGeneratorUtil_Test method toQueryParamVarList_FullList_Test.

@Test
public void toQueryParamVarList_FullList_Test() {
    final ImmutableList<Variable> expected = ImmutableList.of(new Variable("param_one", "strconv.Itoa(paramOne)"), new Variable("param_two", "strconv.FormatFloat(paramTwo, 'f', -1, 64)"), new Variable("param_three", "paramThree"), new Variable("param_four", "\"\""), new Variable("type", "typeName.String()"));
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("ParamOne", "int", false), new Ds3Param("ParamTwo", "float64", false), new Ds3Param("ParamThree", "string", false), new Ds3Param("ParamFour", "void", false), new Ds3Param("Operation", "RestOperationType", false), new Ds3Param("Type", "com.test.TypeName", false));
    final ImmutableList<Variable> result = toQueryParamVarList(params);
    assertThat(result.size(), is(expected.size()));
    for (int i = 0; i < result.size(); i++) {
        assertThat(result.get(i), is(expected.get(i)));
    }
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) Variable(com.spectralogic.ds3autogen.go.models.request.Variable) SimpleVariable(com.spectralogic.ds3autogen.go.models.request.SimpleVariable) Test(org.junit.Test)

Example 35 with Ds3Param

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

the class RequestConverter method getOptionalQueryParams.

private static ImmutableList<Parameter> getOptionalQueryParams(final Ds3Request ds3Request, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Parameter> optionalArgsBuilder = ImmutableList.builder();
    if (isEmpty(ds3Request.getOptionalQueryParams())) {
        return optionalArgsBuilder.build();
    }
    for (final Ds3Param ds3Param : ds3Request.getOptionalQueryParams()) {
        final Parameter optionalQueryParam = ParameterConverter.toParameter(ds3Param, false, toParamDocs(Helper.unqualifiedName(ds3Param.getName()), docSpec));
        LOG.debug("\tOptional QueryParam: " + optionalQueryParam.toString());
        optionalArgsBuilder.add(optionalQueryParam);
    }
    return optionalArgsBuilder.build();
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) ImmutableList(com.google.common.collect.ImmutableList) Parameter(com.spectralogic.ds3autogen.c.models.Parameter)

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