Search in sources :

Example 6 with Ds3ResponseType

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

the class BaseResponseGenerator_Test method toResponsePayloadStruct_Test.

@Test
public void toResponsePayloadStruct_Test() {
    final String expected = "TypeName *TypeName";
    final ImmutableList<Ds3ResponseCode> responseCodes = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.test.TypeName", ""))), new Ds3ResponseCode(204, ImmutableList.of(new Ds3ResponseType("null", ""))));
    final String result = generator.toResponsePayloadStruct(responseCodes);
    assertThat(result, is(expected));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 7 with Ds3ResponseType

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

the class BaseResponseGenerator_Test method toResponseCode_Test.

@Test
public void toResponseCode_Test() {
    final String expectedGoCode = "var body ResponseName\n" + "        if err := readResponseBody(webResponse, &body.TypeName); err != nil {\n" + "            return nil, err\n" + "        }\n" + "        return &body, nil";
    final Ds3ResponseCode responseCode = new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.test.TypeName", "")));
    final ResponseCode result = generator.toResponseCode(responseCode, "ResponseName");
    assertThat(result.getCode(), is(200));
    assertThat(result.getParseResponse(), is(expectedGoCode));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseCode(com.spectralogic.ds3autogen.go.models.response.ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 8 with Ds3ResponseType

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

the class BaseResponseGenerator_Test method getResponsePayload_Test.

@Test
public void getResponsePayload_Test() {
    final String expected = "com.test.Type";
    final ImmutableList<Ds3ResponseCode> input = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.test.Type", ""))), new Ds3ResponseCode(300, ImmutableList.of(new Ds3ResponseType("com.test.ErrorType", ""))));
    final String result = generator.getResponsePayload(input);
    assertThat(result, is(expected));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 9 with Ds3ResponseType

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

the class BaseResponseGenerator_Test method toResponseCode_StringPayload_Test.

@Test
public void toResponseCode_StringPayload_Test() {
    final String expectedGoCode = "content, err := getResponseBodyAsString(webResponse)\n" + "        if err != nil {\n" + "            return nil, err\n" + "        }\n" + "        return &ResponseName{Content: content}, nil";
    final Ds3ResponseCode responseCode = new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("java.lang.String", "")));
    final ResponseCode result = generator.toResponseCode(responseCode, "ResponseName");
    assertThat(result.getCode(), is(200));
    assertThat(result.getParseResponse(), is(expectedGoCode));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseCode(com.spectralogic.ds3autogen.go.models.response.ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 10 with Ds3ResponseType

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

the class BaseResponseGenerator_Test method getResponsePayload_NoPayload_Test.

@Test(expected = IllegalArgumentException.class)
public void getResponsePayload_NoPayload_Test() {
    final ImmutableList<Ds3ResponseCode> input = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of()), new Ds3ResponseCode(204, ImmutableList.of(new Ds3ResponseType("null", ""))), new Ds3ResponseCode(300, ImmutableList.of(new Ds3ResponseType("com.test.Type", ""))));
    generator.getResponsePayload(input);
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Aggregations

Ds3ResponseType (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)35 Test (org.junit.Test)31 Ds3ResponseCode (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode)30 ResponseCode (com.spectralogic.ds3autogen.go.models.response.ResponseCode)6 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)5 ResponseCode (com.spectralogic.ds3autogen.java.models.ResponseCode)2 ImmutableList (com.google.common.collect.ImmutableList)1 Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode (com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode)1 Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode (com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode)1