SHARE
TWEET

Untitled

a guest Oct 12th, 2015 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Skip to content
  2. Sign up Sign in
  3. This repository  
  4. Search
  5. Explore
  6. Features
  7. Enterprise
  8. Pricing
  9.  Watch 1  Star 0  Fork 0 staleks/evidencija-cc
  10. Branch: master  evidencija-cc/src/test/groovy/rs/in/staleksit/evidencija/service/city/impl/CityServiceImplSpec.groovy
  11. @astoisavljevicastoisavljevic a day ago improve code quality
  12. 1 contributor
  13. RawBlameHistory     48 lines (35 sloc)  1.23 KB
  14. package rs.in.staleksit.evidencija.service.city.impl
  15.  
  16. import org.jtransfo.JTransfo
  17.  
  18. import rs.in.staleksit.evidencija.model.city.impl.CityImpl
  19. import rs.in.staleksit.evidencija.model.dto.city.CityDTO;
  20. import rs.in.staleksit.evidencija.model.dto.country.CountryDTO
  21. import rs.in.staleksit.evidencija.repository.CityRepository
  22. import spock.lang.Specification
  23. import spock.lang.Unroll
  24.  
  25. class CityServiceImplSpec extends Specification {
  26.        
  27.         def cityRepository
  28.         def jTransfo
  29.        
  30.         def cityService
  31.  
  32.         def setup() {
  33.             cityRepository = Mock(CityRepository)
  34.             jTransfo = Mock(JTransfo)
  35.             cityService = new CityServiceImpl(cityRepository, jTransfo)
  36.         }
  37.        
  38.         @Unroll
  39.         def "as City entity: '#city' and CityDTO name: '#cityDtoName' cityService findOne should return '#city'"() {
  40.                
  41.                 given:
  42.                 CityDTO cityDTO = new CityDTO(name: cityDtoName)
  43.                
  44.                 when:
  45.                 def result = cityService.findOne(1)
  46.                
  47.                 then:
  48.                 1 * cityRepository.findOne(1) >> city
  49.                 (_..1) * jTransfo.convert(city, new CityDTO()) >> cityDTO
  50.                 result ? result.name == cityDtoName : result == city
  51.                
  52.                 where:
  53.                 city                       | cityDtoName
  54.                 new CityImpl("Novi Sad")   | "Novi Sad"
  55.                 new CityImpl("Beograd")    | "Beograd"
  56.                 null                       | null
  57.         }
  58.  
  59. }
  60. Status API Training Shop Blog About Pricing
  61. © 2015 GitHub, Inc. Terms Privacy Security Contact Help
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top