Advertisement
fedorm

Untitled

Sep 26th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Feature: SR-2326 Сервис для генерации купонов
  2.  
  3.   Background:
  4.     * url serverUrl
  5.     * path "SET-Cards-Coupons/SET/UniqueCouponsWS"
  6.     * def KarateDBHelper = Java.type('ru.crystals.testingtools.ws.karate.KarateDBHelper')
  7.     * def JavaMethods = Java.type('ru.crystals.testingtools.ws.karate.KarateJavaMethods')
  8.     * def TestContext = Java.type('ru.crystals.settester.TestContext')
  9.     * def DbUtils = new KarateDBHelper(TestContext.CENTRUM)
  10.     * string couponCategoryName = "Category-Generated-By-WS"
  11.  
  12.   Scenario: [SR-2317] Проверка генерации категории купонов
  13.     * xmlstring reqXml = read('create_coupons_category.xml')
  14.     Given request reqXml
  15.     When method POST
  16.     Then status 200
  17.     * def couponCategoryId = /Envelope/Body/createCouponsCategoryResponse/guid
  18.     * def couponCategory = DbUtils.readRow('SELECT * FROM CARD_CARDTYPE INNER JOIN CARD_COUPONS ON CARD_CARDTYPE.ID = CARD_COUPONS.ID WHERE CARD_CARDTYPE.GUID = '+ couponCategoryId)
  19.     * match couponCategory contains { name: '#(couponCategoryName)', name_for_client: 'Random', description: 'Random'}
  20.       #Доделать дату
  21. #   * match couponCategory contains { activationdate: '2000-01-01 00:00:00.0', expirationdate: '2020-01-01 04:04:04.0'}
  22.  
  23.   Scenario: [SR-2318] Проверка создания экземпляра купона
  24.     * def query = "SELECT id FROM card_cardtype WHERE name = '" + couponCategoryName + "' LIMIT 1"
  25.     * def couponCategoryId = DbUtils.readValue(query)
  26.     * def clientGuid = JavaMethods.createClientInDb(TestContext.CENTRUM)
  27.     * xmlstring reqXml = read('create_unique_coupon.xml')
  28.     Given request reqXml
  29.     When method POST
  30.     Then status 200
  31.     * def couponNumber = /Envelope/Body/generateCouponsResponse/coupons/coupon/couponNumber
  32.     * def couponEntityFromDB = DbUtils.readRow('SELECT * FROM CARD_UNIQUE_COUPON_EXEMPLAR LEFT JOIN CARD_CLIENTS ON CARD_UNIQUE_COUPON_EXEMPLAR.CLIENT_ID = CARD_CLIENTS.ID LEFT JOIN CARD_CARDTYPE ON CARD_UNIQUE_COUPON_EXEMPLAR.CARDTYPE_ID = CARD_CARDTYPE.ID  WHERE CARD_UNIQUE_COUPON_EXEMPLAR.NUMBERFIELD = '+ couponNumber + ' ::text')
  33.     * match couponEntityFromDB contains { cardtype_id: '#(couponCategoryId)', issuance_purchase_number: 1, issuance_shift_number: 2, issuance_shop_number: 3, numberfield: '#(couponNumber)'}
  34.  
  35.   Scenario: [SR-2326] - Получение информации по купону по его номеру из внешней системы
  36.     * def query = "SELECT numberfield FROM card_unique_coupon_exemplar WHERE cardtype_id = (SELECT id FROM card_cardtype WHERE name = '" + couponCategoryName + "' LIMIT 1) LIMIT 1"
  37.     * def couponNumberfield = DbUtils.readValue(query)
  38.     * xmlstring reqXml = read('find_coupon_by_number.xml')
  39.     Given request reqXml
  40.     When method POST
  41.     Then status 200
  42.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/number == "#(couponNumberfield)"
  43.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/status == "Create"
  44.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/client/guid != null
  45.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/distributionReceipt/purchaseNumber == "1"
  46.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/distributionReceipt/shiftNumber == "2"
  47.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/distributionReceipt/shopNumber == "3"
  48.  
  49.   Scenario: [SR-2327] - Получение информации о купонах по клиенту из внешней системы
  50.     * def query = "SELECT card_clients.guid FROM card_clients LEFT JOIN card_unique_coupon_exemplar ON CARD_UNIQUE_COUPON_EXEMPLAR.CLIENT_ID = CARD_CLIENTS.ID LEFT JOIN CARD_CARDTYPE ON CARD_UNIQUE_COUPON_EXEMPLAR.CARDTYPE_ID = CARD_CARDTYPE.ID WHERE card_cardtype.name = '" + couponCategoryName + "' LIMIT 1"
  51.     * def clientGuid = DbUtils.readValue(query)
  52.     * def query = "SELECT numberfield FROM card_unique_coupon_exemplar WHERE cardtype_id = (SELECT id FROM card_cardtype WHERE name = '" + couponCategoryName + "' LIMIT 1) LIMIT 1"
  53.     * def couponNumberfield = DbUtils.readValue(query)
  54.     * xmlstring reqXml = read('find_coupon_by_client.xml')
  55.     Given request reqXml
  56.     When method POST
  57.     Then status 200
  58.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/number == "#(couponNumberfield)"
  59.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/status == "Create"
  60.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/client/guid != null
  61.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/distributionReceipt/purchaseNumber == "1"
  62.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/distributionReceipt/shiftNumber == "2"
  63.     And match response /Envelope/Body/findCouponExemplarsResponse/exemplars/distributionReceipt/shopNumber == "3"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement