Guest User

Untitled

a guest
Feb 17th, 2018
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. Feature: person mock server
  2.  
  3. Background:
  4. * def persons =
  5. """
  6. {
  7. '1': { id: 1, firstName: 'FN1', lastName: 'LN1', email: 'email1@email.com' },
  8. '2': { id: 2, firstName: 'FN2', lastName: 'LN2', email: 'email2@email.com' },
  9. '3': { id: 3, firstName: 'FN3', lastName: 'LN3', email: 'email3@email.com' },
  10. '4': { id: 4, firstName: 'FN4', lastName: 'LN4', email: 'email4@email.com' }
  11. }
  12. """
  13.  
  14. Scenario: pathMatches('/person/get/{id}')
  15. * def response = persons[pathParams.id]
  16.  
  17. Scenario: pathMatches('/person/remove')
  18. * def list = $persons.*
  19. * eval if (list.length) karate.remove('persons', '$.' + list[0].id)
  20.  
  21. Scenario: pathMatches('/person/all')
  22. * def response = $persons.*
  23.  
  24. Scenario: methodIs('post')
  25. * def person = request
  26. * def id = person.id || ~~(persons.length + 1)
  27. * set person.id = id
  28. * eval persons[id + ''] = person
  29. * def response = person
Add Comment
Please, Sign In to add comment