-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests for LoaderOperationPlugin
- Loading branch information
1 parent
d48d49f
commit 3d0853f
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/test/groovy/com/github/springfox/loader/plugins/LoaderOperationPluginSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.github.springfox.loader.plugins | ||
|
||
import spock.lang.Specification | ||
import springfox.documentation.builders.OperationBuilder | ||
import springfox.documentation.service.Operation | ||
import springfox.documentation.spi.DocumentationType | ||
import springfox.documentation.spi.service.contexts.OperationContext | ||
|
||
class LoaderOperationPluginSpec extends Specification { | ||
private OperationContext context | ||
private OperationBuilder builder | ||
|
||
void setup() { | ||
builder = Mock(OperationBuilder) { | ||
build() >> Mock(Operation) { | ||
getSummary() >> 'MyTest' | ||
} | ||
} | ||
context = Mock(OperationContext) { | ||
operationBuilder() >> builder | ||
} | ||
} | ||
|
||
def "Update summary when creating LoaderOperationPlugin with conventionMode enabled"() { | ||
when: | ||
def plugin = new LoaderOperationPlugin(true) | ||
plugin.apply(context) | ||
|
||
then: | ||
1 * builder.summary('My test') | ||
} | ||
|
||
def "Do not update summary when creating LoaderOperationPlugin with conventionMode disabled"() { | ||
when: | ||
def plugin = new LoaderOperationPlugin(false) | ||
plugin.apply(context) | ||
|
||
then: | ||
0 * builder.summary(_ as String) | ||
} | ||
|
||
def "Return true on supports swagger 2 documentation type"() { | ||
given: | ||
def plugin = new LoaderOperationPlugin(true) | ||
|
||
when: | ||
def supports = plugin.supports(DocumentationType.SWAGGER_2) | ||
|
||
then: | ||
supports | ||
} | ||
|
||
def "Return false on supports swagger 1.2 documentation type"() { | ||
given: | ||
def plugin = new LoaderOperationPlugin(true) | ||
|
||
when: | ||
def supports = plugin.supports(DocumentationType.SWAGGER_12) | ||
|
||
then: | ||
!supports | ||
} | ||
} |