|
| 1 | +/** |
| 2 | + * Copyright (C) 2009-2017 Slava Semushin <slava.semushin@gmail.com> |
| 3 | + * |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program; if not, write to the Free Software |
| 16 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | + */ |
| 18 | +package ru.mystamps.web.service |
| 19 | + |
| 20 | +import static io.qala.datagen.RandomShortApi.nullOrBlank |
| 21 | + |
| 22 | +import org.slf4j.helpers.NOPLogger |
| 23 | + |
| 24 | +import spock.lang.Specification |
| 25 | + |
| 26 | +@SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) |
| 27 | +class SeriesInfoExtractorServiceImplTest extends Specification { |
| 28 | + |
| 29 | + private final CategoryService categoryService = Mock() |
| 30 | + private final CountryService countryService = Mock() |
| 31 | + private final SeriesInfoExtractorService service = new SeriesInfoExtractorServiceImpl( |
| 32 | + NOPLogger.NOP_LOGGER, |
| 33 | + categoryService, |
| 34 | + countryService |
| 35 | + ) |
| 36 | + |
| 37 | + // |
| 38 | + // Tests for extractCategory() |
| 39 | + // |
| 40 | + |
| 41 | + def 'extractCategory() should return empty result when fragment is null, empty or blank'() { |
| 42 | + given: |
| 43 | + String fragment = nullOrBlank() |
| 44 | + when: |
| 45 | + List<Integer> result = service.extractCategory(fragment) |
| 46 | + then: |
| 47 | + result.isEmpty() |
| 48 | + } |
| 49 | + |
| 50 | + // |
| 51 | + // Tests for extractCountry() |
| 52 | + // |
| 53 | + |
| 54 | + def 'extractCountry() should return empty result when fragment is null, empty or blank'() { |
| 55 | + given: |
| 56 | + String fragment = nullOrBlank() |
| 57 | + when: |
| 58 | + List<Integer> result = service.extractCountry(fragment) |
| 59 | + then: |
| 60 | + result.isEmpty() |
| 61 | + } |
| 62 | + |
| 63 | + // |
| 64 | + // Tests for extractReleaseYear() |
| 65 | + // |
| 66 | + |
| 67 | + def 'extractReleaseYear() should return null when fragment is null, empty or blank'() { |
| 68 | + given: |
| 69 | + String fragment = nullOrBlank() |
| 70 | + when: |
| 71 | + Integer year = service.extractReleaseYear(fragment) |
| 72 | + then: |
| 73 | + year == null |
| 74 | + } |
| 75 | + |
| 76 | +} |
0 commit comments