|
| 1 | +/** |
| 2 | + * Copyright (C) 2009-2018 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.nullOr |
| 21 | + |
| 22 | +import org.slf4j.helpers.NOPLogger |
| 23 | + |
| 24 | +import spock.lang.Specification |
| 25 | + |
| 26 | +import ru.mystamps.web.service.dto.RawParsedDataDto |
| 27 | +import ru.mystamps.web.service.dto.SeriesExtractedInfo |
| 28 | + |
| 29 | +@SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace']) |
| 30 | +class TimedSeriesInfoExtractorServiceTest extends Specification { |
| 31 | + |
| 32 | + private final SeriesInfoExtractorService origService = Mock() |
| 33 | + |
| 34 | + private SeriesInfoExtractorService service |
| 35 | + |
| 36 | + def setup() { |
| 37 | + service = new TimedSeriesInfoExtractorService(NOPLogger.NOP_LOGGER, origService) |
| 38 | + } |
| 39 | + |
| 40 | + // |
| 41 | + // Tests for extract() |
| 42 | + // |
| 43 | + |
| 44 | + def 'extract() should invoke original service and return its result'() { |
| 45 | + given: |
| 46 | + RawParsedDataDto expectedParsedData = TestObjects.createRawParsedDataDto() |
| 47 | + SeriesExtractedInfo expectedResult = nullOr(TestObjects.createSeriesExtractedInfo()) |
| 48 | + when: |
| 49 | + SeriesExtractedInfo result = service.extract(expectedParsedData) |
| 50 | + then: |
| 51 | + 1 * origService.extract(expectedParsedData) >> expectedResult |
| 52 | + and: |
| 53 | + result == expectedResult |
| 54 | + } |
| 55 | + |
| 56 | +} |
0 commit comments