|
| 1 | +package com.github.magneticflux.rss.namespaces.standard.elements |
| 2 | + |
| 3 | +import com.github.magneticflux.rss.PersisterSpecification |
| 4 | +import spock.lang.Unroll |
| 5 | + |
| 6 | +import static com.github.magneticflux.rss.UrlUtils.testUrl |
| 7 | + |
| 8 | +class ImageTest extends PersisterSpecification { |
| 9 | + @Unroll |
| 10 | + def 'enclosure #object read/write'() { |
| 11 | + |
| 12 | + expect: 'the output XML equals the given XML' |
| 13 | + persister.write(object) == xml |
| 14 | + |
| 15 | + and: 'the input object equals the given object' |
| 16 | + persister.read(Image, xml) == object |
| 17 | + |
| 18 | + where: |
| 19 | + url | title | link | description | widthRaw | heightRaw | xml |
| 20 | + testUrl() | 'testTitle' | testUrl() | 'testDescription' | '100' | '100' | """<image> |
| 21 | + | <url>$url</url> |
| 22 | + | <title>$title</title> |
| 23 | + | <link>$link</link> |
| 24 | + | <description>$description</description> |
| 25 | + | <width>$widthRaw</width> |
| 26 | + | <height>$heightRaw</height> |
| 27 | + |</image>""".stripMargin() |
| 28 | + |
| 29 | + testUrl() | 'testTitle' | testUrl() | null | '100' | '100' | """<image> |
| 30 | + | <url>$url</url> |
| 31 | + | <title>$title</title> |
| 32 | + | <link>$link</link> |
| 33 | + | <width>$widthRaw</width> |
| 34 | + | <height>$heightRaw</height> |
| 35 | + |</image>""".stripMargin() |
| 36 | + |
| 37 | + testUrl() | 'testTitle' | testUrl() | 'testDescription' | null | '100' | """<image> |
| 38 | + | <url>$url</url> |
| 39 | + | <title>$title</title> |
| 40 | + | <link>$link</link> |
| 41 | + | <description>$description</description> |
| 42 | + | <height>$heightRaw</height> |
| 43 | + |</image>""".stripMargin() |
| 44 | + |
| 45 | + testUrl() | 'testTitle' | testUrl() | 'testDescription' | '100' | null | """<image> |
| 46 | + | <url>$url</url> |
| 47 | + | <title>$title</title> |
| 48 | + | <link>$link</link> |
| 49 | + | <description>$description</description> |
| 50 | + | <width>$widthRaw</width> |
| 51 | + |</image>""".stripMargin() |
| 52 | + |
| 53 | + object = new Image(url, title, link, description, widthRaw, heightRaw) |
| 54 | + } |
| 55 | +} |
0 commit comments