Skip to content

Commit 7a90d39

Browse files
committed
log mock fails on github ci
1 parent a1a54b9 commit 7a90d39

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dependencies {
5252
}
5353
testImplementation 'org.spockframework:spock-junit4:2.0-M2-groovy-3.0'
5454
testImplementation 'net.bytebuddy:byte-buddy:1.9.13'
55+
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
5556

5657
testIntImplementation "com.github.hauner.openapi:openapi-generatr-api:$generatrApiVersion"
5758
testIntImplementation 'io.github.java-diff-utils:java-diff-utils:4.5'

src/test/groovy/com/github/hauner/openapi/spring/converter/ApiConverterErrorSpec.groovy

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
@@ -16,18 +16,28 @@
1616

1717
package 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
2322
import spock.lang.Specification
23+
import spock.lang.Subject
2424

2525
import static com.github.hauner.openapi.spring.support.OpenApiParser.parse
2626

2727
class 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
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<configuration />

0 commit comments

Comments
 (0)