Reformatted test to match code style
/*
*
- * Copyright 2015-2016 the original author or authors.
+ * Copyright 2015-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ import springfox.documentation.spring.web.paths.AbstractPathProvider
import springfox.documentation.spring.web.paths.RelativePathProvider
import springfox.documentation.spring.web.plugins.DocumentationContextSpec
-import static com.google.common.collect.Maps.newHashMap
-import static springfox.documentation.builders.PathSelectors.regex
+import static com.google.common.collect.Maps.*
+import static springfox.documentation.builders.PathSelectors.*
@Mixin([RequestMappingSupport])
class SwaggerApiDocumentationScannerSpec extends DocumentationContextSpec {
@@ -45,6 +45,7 @@ class SwaggerApiDocumentationScannerSpec extends DocumentationContextSpec {
when: "I create a swagger resource"
listingReferenceScanner.scan(_) >> new ApiListingReferenceScanResult(newHashMap())
listingScanner.scan(_) >> LinkedListMultimap.create()
+
and:
Documentation scanned = swaggerApiResourceListing.scan(context())
@@ -64,6 +65,7 @@ class SwaggerApiDocumentationScannerSpec extends DocumentationContextSpec {
def "resource with api info"() {
given:
ApiInfo expected = new ApiInfo("title", "description", "1.0", "terms", "contact", "license", "licenseUrl")
+
when:
plugin
.groupName("groupName")
@@ -74,8 +76,10 @@ class SwaggerApiDocumentationScannerSpec extends DocumentationContextSpec {
.configure(contextBuilder)
listingReferenceScanner.scan(_) >> new ApiListingReferenceScanResult(newHashMap())
listingScanner.scan(_) >> LinkedListMultimap.create()
+
and:
Documentation scanned = swaggerApiResourceListing.scan(context())
+
then:
ApiInfo actual = scanned.getResourceListing().getInfo()
actual.getTitle() == expected.getTitle()
@@ -90,6 +94,7 @@ class SwaggerApiDocumentationScannerSpec extends DocumentationContextSpec {
def "resource with authorization types"() {
given:
ApiKey apiKey = new ApiKey("mykey", "api_key", "header",)
+
when:
plugin
.groupName("groupName")
@@ -100,8 +105,10 @@ class SwaggerApiDocumentationScannerSpec extends DocumentationContextSpec {
.configure(contextBuilder)
listingReferenceScanner.scan(_) >> new ApiListingReferenceScanResult(newHashMap())
listingScanner.scan(_) >> LinkedListMultimap.create()
+
and:
Documentation scanned = swaggerApiResourceListing.scan(context())
+
then:
ResourceListing resourceListing = scanned.resourceListing
def authorizationTypes = resourceListing.getSecuritySchemes()
@@ -125,13 +132,16 @@ class SwaggerApiDocumentationScannerSpec extends DocumentationContextSpec {
RequestMappingContext requestMappingContext = new RequestMappingContext(context(),
new WebMvcRequestHandler(requestMappingInfo("somePath/"), dummyHandlerMethod()))
+
and:
def mockListingRef = Mock(ApiListingReference)
mockListingRef.path >> "/some/path"
+
when:
listingReferenceScanner.scan(_) >>
new ApiListingReferenceScanResult([resourceGroup: [requestMappingContext]])
listingScanner.scan(_) >> LinkedListMultimap.create()
+
and:
Documentation scanned = swaggerApiResourceListing.scan(context())
scanned.resourceListing != null
@@ -167,6 +177,7 @@ class SwaggerApiDocumentationScannerSpec extends DocumentationContextSpec {
when:
Documentation scanned = swaggerApiResourceListing.scan(context())
+
then:
scanned.resourceListing.apis.size() == 1
scanned.resourceListing.apis.get(0).path == "/groupName/test"
