11/*
2- * Copyright 2019 the original authors
2+ * Copyright 2019-2020 the original authors
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package com.github.hauner.openapi.spring.converter
1818
19- import com.github.hauner.openapi.spring.model.Api
20- import com.github.hauner.openapi.spring.support.Sl4jMockRule
21- import org.junit.Rule
22- import org.slf4j.Logger
19+ import ch.qos.logback.classic.Level
20+ import ch.qos.logback.classic.spi.ILoggingEvent
21+ import ch.qos.logback.core.read.ListAppender
2322import spock.lang.Specification
23+ import spock.lang.Subject
2424
2525import static com.github.hauner.openapi.spring.support.OpenApiParser.parse
2626
2727class ApiConverterErrorSpec extends Specification {
2828
29- def log = Mock Logger
30- @Rule Sl4jMockRule rule = new Sl4jMockRule (ApiConverter , log)
29+ @Subject
30+ def converter
31+
32+ def appender
33+
34+ void setup () {
35+ converter = new ApiConverter ()
36+
37+ appender = new ListAppender<ILoggingEvent > ()
38+ appender. start ()
39+ converter. log. addAppender (appender)
40+ }
3141
3242 void " logs error when datatype conversion fails" () {
3343 def openApi = parse (""" \
@@ -48,12 +58,12 @@ paths:
4858 type: unknown
4959""" )
5060 when :
51- log. isErrorEnabled () >> true
52- Api api = new ApiConverter (). convert (openApi)
61+ converter. convert (openApi)
5362
5463 then :
5564 notThrown (UnknownDataTypeException )
56- 1 * log. error (* _)
65+ appender. list. size () == 1
66+ appender. list. first (). level == Level . ERROR
5767 }
5868
5969}
0 commit comments