Skip to content

Commit 3d0853f

Browse files
committed
added tests for LoaderOperationPlugin
1 parent d48d49f commit 3d0853f

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.github.springfox.loader.plugins
2+
3+
import spock.lang.Specification
4+
import springfox.documentation.builders.OperationBuilder
5+
import springfox.documentation.service.Operation
6+
import springfox.documentation.spi.DocumentationType
7+
import springfox.documentation.spi.service.contexts.OperationContext
8+
9+
class LoaderOperationPluginSpec extends Specification {
10+
private OperationContext context
11+
private OperationBuilder builder
12+
13+
void setup() {
14+
builder = Mock(OperationBuilder) {
15+
build() >> Mock(Operation) {
16+
getSummary() >> 'MyTest'
17+
}
18+
}
19+
context = Mock(OperationContext) {
20+
operationBuilder() >> builder
21+
}
22+
}
23+
24+
def "Update summary when creating LoaderOperationPlugin with conventionMode enabled"() {
25+
when:
26+
def plugin = new LoaderOperationPlugin(true)
27+
plugin.apply(context)
28+
29+
then:
30+
1 * builder.summary('My test')
31+
}
32+
33+
def "Do not update summary when creating LoaderOperationPlugin with conventionMode disabled"() {
34+
when:
35+
def plugin = new LoaderOperationPlugin(false)
36+
plugin.apply(context)
37+
38+
then:
39+
0 * builder.summary(_ as String)
40+
}
41+
42+
def "Return true on supports swagger 2 documentation type"() {
43+
given:
44+
def plugin = new LoaderOperationPlugin(true)
45+
46+
when:
47+
def supports = plugin.supports(DocumentationType.SWAGGER_2)
48+
49+
then:
50+
supports
51+
}
52+
53+
def "Return false on supports swagger 1.2 documentation type"() {
54+
given:
55+
def plugin = new LoaderOperationPlugin(true)
56+
57+
when:
58+
def supports = plugin.supports(DocumentationType.SWAGGER_12)
59+
60+
then:
61+
!supports
62+
}
63+
}

0 commit comments

Comments
 (0)