src/test/java/com/squareup/connect/api/CatalogApiTest.java
@Test
    public void upsertCatalogObjectTest() throws ApiException {
        UpsertCatalogObjectRequest body = new UpsertCatalogObjectRequest()
            .idempotencyKey(UUID.randomUUID().toString())
            .object(new CatalogObject()
                .type("DISCOUNT")
                .id("#Discount")
                .discountData(new CatalogDiscount()
                    .name("Half off")
                    .percentage("50.0")
                )
            );
        UpsertCatalogObjectResponse response = api.upsertCatalogObject(body);

        assertEquals("Half off", response.getCatalogObject().getDiscountData().getName());
        assertNotNull(response.getCatalogObject().getId());
        assertNotNull(response.getCatalogObject().getUpdatedAt());
        assertNotNull(response.getCatalogObject().getVersion());
        assertFalse(response.getCatalogObject().getIsDeleted());

        assertEquals(1, response.getIdMappings().size());
        assertEquals("#Discount", response.getIdMappings().get(0).getClientObjectId());
    }
/**
     * UpsertCatalogObject
     * <p>
     * Creates or updates the target [CatalogObject](#type-catalogobject).
     *
     * @throws ApiException if the Api call fails
     */
UpsertCatalogObject

Creates or updates the target [CatalogObject](#type-catalogobject).

@throws ApiException if the Api call fails
UpsertCatalogObject Creates or updates the target [ CatalogObject ] ( #type - catalogobject ) . @throws ApiException if the Api call fails
@Test
    public void upsertCatalogObjectTest() throws ApiException {
        UpsertCatalogObjectRequest body = new UpsertCatalogObjectRequest()
            .idempotencyKey(UUID.randomUUID().toString())
            .object(new CatalogObject()
                .type("DISCOUNT")
                .id("#Discount")
                .discountData(new CatalogDiscount()
                    .name("Half off")
                    .percentage("50.0")
                )
            );
        UpsertCatalogObjectResponse response = api.upsertCatalogObject(body);
        assertEquals("Half off", response.getCatalogObject().getDiscountData().getName());
        assertNotNull(response.getCatalogObject().getId());
        assertNotNull(response.getCatalogObject().getUpdatedAt());
        assertNotNull(response.getCatalogObject().getVersion());
        assertFalse(response.getCatalogObject().getIsDeleted());
        assertEquals(1, response.getIdMappings().size());
        assertEquals("#Discount", response.getIdMappings().get(0).getClientObjectId());
    }
@ Test public void upsertCatalogObjectTest ( ) throws ApiException { UpsertCatalogObjectRequest body = new UpsertCatalogObjectRequest ( ) . idempotencyKey ( UUID . randomUUID ( ) . toString ( ) ) . object ( new CatalogObject ( ) . type ( "DISCOUNT" ) . id ( "#Discount" ) . discountData ( new CatalogDiscount ( ) . name ( "Half off" ) . percentage ( "50.0" ) ) ) ; UpsertCatalogObjectResponse response = api . upsertCatalogObject ( body ) ; assertEquals ( "Half off" , response . getCatalogObject ( ) . getDiscountData ( ) . getName ( ) ) ; assertNotNull ( response . getCatalogObject ( ) . getId ( ) ) ; assertNotNull ( response . getCatalogObject ( ) . getUpdatedAt ( ) ) ; assertNotNull ( response . getCatalogObject ( ) . getVersion ( ) ) ; assertFalse ( response . getCatalogObject ( ) . getIsDeleted ( ) ) ; assertEquals ( 1 , response . getIdMappings ( ) . size ( ) ) ; assertEquals ( "#Discount" , response . getIdMappings ( ) . get ( 0 ) . getClientObjectId ( ) ) ; }
UpsertCatalogObject
 <p>
 Creates or updates the target [CatalogObject](#type-catalogobject).
UpsertCatalogObject <p > Creates or updates the target [ CatalogObject ] ( #type - catalogobject ) .