Search in sources :

Example 1 with SimpleProduct

use of fixtures.modelflattening.models.SimpleProduct in project autorest.java by Azure.

the class ModelFlatteningTests method putSimpleProductWithGrouping.

@Test
public void putSimpleProductWithGrouping() throws Exception {
    SimpleProduct simpleProduct = new SimpleProduct();
    simpleProduct.withDescription("product description");
    simpleProduct.withProductId("123");
    simpleProduct.withMaxProductDisplayName("max name");
    simpleProduct.withCapacity("Large");
    simpleProduct.withOdatavalue("http://foo");
    FlattenParameterGroup flattenParameterGroup = new FlattenParameterGroup();
    flattenParameterGroup.withDescription("product description");
    flattenParameterGroup.withProductId("123");
    flattenParameterGroup.withMaxProductDisplayName("max name");
    flattenParameterGroup.withOdatavalue("http://foo");
    flattenParameterGroup.withName("groupproduct");
    SimpleProduct product = client.putSimpleProductWithGrouping(flattenParameterGroup);
    assertSimpleProductEquals(simpleProduct, product);
}
Also used : SimpleProduct(fixtures.modelflattening.models.SimpleProduct) FlattenParameterGroup(fixtures.modelflattening.models.FlattenParameterGroup) Test(org.junit.Test)

Example 2 with SimpleProduct

use of fixtures.modelflattening.models.SimpleProduct in project autorest.java by Azure.

the class ModelFlatteningTests method putSimpleProduct.

@Test
public void putSimpleProduct() throws Exception {
    SimpleProduct simpleProduct = new SimpleProduct();
    simpleProduct.withDescription("product description");
    simpleProduct.withProductId("123");
    simpleProduct.withMaxProductDisplayName("max name");
    simpleProduct.withCapacity("Large");
    simpleProduct.withOdatavalue("http://foo");
    simpleProduct.withGenericValue("https://generic");
    SimpleProduct product = client.putSimpleProduct(simpleProduct);
    assertSimpleProductEquals(simpleProduct, product);
}
Also used : SimpleProduct(fixtures.modelflattening.models.SimpleProduct) Test(org.junit.Test)

Example 3 with SimpleProduct

use of fixtures.modelflattening.models.SimpleProduct in project autorest.java by Azure.

the class AutoRestResourceFlatteningTestServiceImpl method postFlattenedSimpleProductWithServiceResponseAsync.

/**
 * Put Flattened Simple Product with client flattening true on the parameter.
 *
 * @param productId Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles.
 * @param maxProductDisplayName Display name of product.
 * @param description Description of product.
 * @param genericValue Generic URL value.
 * @param odatavalue URL value.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable to the SimpleProduct object
 */
public Observable<ServiceResponse<SimpleProduct>> postFlattenedSimpleProductWithServiceResponseAsync(String productId, String maxProductDisplayName, String description, String genericValue, String odatavalue) {
    if (productId == null) {
        throw new IllegalArgumentException("Parameter productId is required and cannot be null.");
    }
    if (maxProductDisplayName == null) {
        throw new IllegalArgumentException("Parameter maxProductDisplayName is required and cannot be null.");
    }
    SimpleProduct simpleBodyProduct = null;
    if (description != null || genericValue != null || odatavalue != null) {
        simpleBodyProduct = new SimpleProduct();
        simpleBodyProduct.withProductId(productId);
        simpleBodyProduct.withDescription(description);
        simpleBodyProduct.withMaxProductDisplayName(maxProductDisplayName);
        simpleBodyProduct.withGenericValue(genericValue);
        simpleBodyProduct.withOdatavalue(odatavalue);
    }
    return service.postFlattenedSimpleProduct(simpleBodyProduct).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<SimpleProduct>>>() {

        @Override
        public Observable<ServiceResponse<SimpleProduct>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<SimpleProduct> clientResponse = postFlattenedSimpleProductDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) SimpleProduct(fixtures.modelflattening.models.SimpleProduct) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Example 4 with SimpleProduct

use of fixtures.modelflattening.models.SimpleProduct in project autorest.java by Azure.

the class ModelFlatteningTests method postFlattenedSimpleProduct.

@Test
public void postFlattenedSimpleProduct() throws Exception {
    SimpleProduct simpleProduct = new SimpleProduct();
    simpleProduct.withDescription("product description");
    simpleProduct.withProductId("123");
    simpleProduct.withMaxProductDisplayName("max name");
    simpleProduct.withCapacity("Large");
    simpleProduct.withOdatavalue("http://foo");
    client.postFlattenedSimpleProduct("123", "max name", "product description", null, "http://foo");
}
Also used : SimpleProduct(fixtures.modelflattening.models.SimpleProduct) Test(org.junit.Test)

Example 5 with SimpleProduct

use of fixtures.modelflattening.models.SimpleProduct in project autorest.java by Azure.

the class AutoRestResourceFlatteningTestServiceImpl method putSimpleProductWithGroupingWithServiceResponseAsync.

/**
 * Put Simple Product with client flattening true on the model.
 *
 * @param flattenParameterGroup Additional parameters for the operation
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable to the SimpleProduct object
 */
public Observable<ServiceResponse<SimpleProduct>> putSimpleProductWithGroupingWithServiceResponseAsync(FlattenParameterGroup flattenParameterGroup) {
    if (flattenParameterGroup == null) {
        throw new IllegalArgumentException("Parameter flattenParameterGroup is required and cannot be null.");
    }
    Validator.validate(flattenParameterGroup);
    String name = flattenParameterGroup.name();
    String productId = flattenParameterGroup.productId();
    String description = flattenParameterGroup.description();
    String maxProductDisplayName = flattenParameterGroup.maxProductDisplayName();
    String genericValue = flattenParameterGroup.genericValue();
    String odatavalue = flattenParameterGroup.odatavalue();
    SimpleProduct simpleBodyProduct = null;
    if (description != null || genericValue != null || odatavalue != null) {
        simpleBodyProduct = new SimpleProduct();
        simpleBodyProduct.withProductId(productId);
        simpleBodyProduct.withDescription(description);
        simpleBodyProduct.withMaxProductDisplayName(maxProductDisplayName);
        simpleBodyProduct.withGenericValue(genericValue);
        simpleBodyProduct.withOdatavalue(odatavalue);
    }
    return service.putSimpleProductWithGrouping(name, simpleBodyProduct).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<SimpleProduct>>>() {

        @Override
        public Observable<ServiceResponse<SimpleProduct>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<SimpleProduct> clientResponse = putSimpleProductWithGroupingDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) SimpleProduct(fixtures.modelflattening.models.SimpleProduct) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

SimpleProduct (fixtures.modelflattening.models.SimpleProduct)5 Test (org.junit.Test)3 ServiceResponse (com.microsoft.rest.ServiceResponse)2 ResponseBody (okhttp3.ResponseBody)2 Response (retrofit2.Response)2 Observable (rx.Observable)2 FlattenParameterGroup (fixtures.modelflattening.models.FlattenParameterGroup)1