Skip to content

Commit cce8dab

Browse files
committed
TimedSeriesInfoExtractorService: add unit test.
Fix #808
1 parent da81886 commit cce8dab

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

src/main/java/ru/mystamps/web/service/TimedSeriesInfoExtractorService.java

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import ru.mystamps.web.service.dto.RawParsedDataDto;
2727
import ru.mystamps.web.service.dto.SeriesExtractedInfo;
2828

29-
// @todo #802 TimedSeriesInfoExtractorService: add unit tests
3029
@RequiredArgsConstructor
3130
public class TimedSeriesInfoExtractorService implements SeriesInfoExtractorService {
3231

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)