Search in sources :

Example 1 with ResponseCode

use of com.spectralogic.ds3autogen.go.models.response.ResponseCode in project ds3_autogen by SpectraLogic.

the class BaseResponseGenerator_Test method toResponseCodeList_Test.

@Test
public void toResponseCodeList_Test() {
    final ImmutableList<ResponseCode> expectedCodes = ImmutableList.of(new ResponseCode(200, "var body ResponseName\n" + "        if err := readResponseBody(webResponse, &body.TypeName); err != nil {\n" + "            return nil, err\n" + "        }\n" + "        return &body, nil"), new ResponseCode(204, "return &ResponseName{}, nil"));
    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 ImmutableList<ResponseCode> result = generator.toResponseCodeList(responseCodes, "ResponseName");
    expectedCodes.forEach(expected -> assertThat(result, hasItem(expected)));
}
Also used : ResponseCode(com.spectralogic.ds3autogen.go.models.response.ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 2 with ResponseCode

use of com.spectralogic.ds3autogen.go.models.response.ResponseCode in project ds3_autogen by SpectraLogic.

the class BaseResponseGenerator_Test method toPayloadResponseCode_Test.

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

Example 3 with ResponseCode

use of com.spectralogic.ds3autogen.go.models.response.ResponseCode in project ds3_autogen by SpectraLogic.

the class GetObjectResponseGenerator_Test method toResponseCode_200_Test.

@Test
public void toResponseCode_200_Test() {
    final ResponseCode expected = new ResponseCode(200, "return &GetObjectResponse{ Content: webResponse.Body() }, nil");
    final Ds3ResponseCode code = new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("null", null)));
    final ResponseCode result = generator.toResponseCode(code, "GetObjectResponse");
    assertThat(result, is(expected));
}
Also used : ResponseCode(com.spectralogic.ds3autogen.go.models.response.ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 4 with ResponseCode

use of com.spectralogic.ds3autogen.go.models.response.ResponseCode 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 5 with ResponseCode

use of com.spectralogic.ds3autogen.go.models.response.ResponseCode 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)

Aggregations

Ds3ResponseCode (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode)9 ResponseCode (com.spectralogic.ds3autogen.go.models.response.ResponseCode)9 Test (org.junit.Test)9 Ds3ResponseType (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)6