review fixes

This commit is contained in:
Milosz Rembisz
2015-12-02 12:56:51 +01:00
committed by Milosz Rembisz
parent 683fb9b732
commit 61e435e543
6 changed files with 10 additions and 8 deletions

View File

@@ -30,7 +30,7 @@ class MockMvcSpockMethodBodyBuilder extends SpockMethodBodyBuilder {
bb.addLine(".body('''$bodyAsString''')")
}
if (request.multipart) {
multipartParameters.each { entry -> bb.addLine(getMultipartParameterLine(entry)) }
multipartParameters?.each { Map.Entry<String, Object> entry -> bb.addLine(getMultipartParameterLine(entry)) }
}
bb.unindent()
}

View File

@@ -123,7 +123,7 @@ abstract class SpockMethodBodyBuilder {
}
protected Map<String, Object> getMultipartParameters() {
return (Map<String, Object>)request.multipart.serverValue
return (Map<String, Object>)request?.multipart?.serverValue
}
protected String getMultipartParameterLine(Map.Entry<String, Object> parameter) {

View File

@@ -53,7 +53,7 @@ class Common {
}
NamedProperty named(Map<String, DslProperty> namedMap){
return new NamedProperty(namedMap.get('name'), namedMap.get('content'))
return new NamedProperty(namedMap)
}
DslProperty value(ClientDslProperty client, ServerDslProperty server) {

View File

@@ -14,7 +14,7 @@ class Multipart extends DslProperty {
}
private static Map<String, Object> extractValue(Map<String, DslProperty> multipart, Closure valueProvider) {
multipart.collectEntries { Map.Entry<String, DslProperty> entry ->
return multipart.collectEntries { Map.Entry<String, DslProperty> entry ->
[(entry.key): valueProvider(entry.value)]
} as Map<String, Object>
}

View File

@@ -9,6 +9,8 @@ import groovy.transform.ToString
@CompileStatic
class NamedProperty {
private static final String NAME = 'name'
private static final String CONTENT = 'content'
DslProperty name
DslProperty value
@@ -16,4 +18,8 @@ class NamedProperty {
this.name = name
this.value = value
}
NamedProperty(Map<String, DslProperty> namedMap) {
this(namedMap?.get(NAME), namedMap?.get(CONTENT))
}
}

View File

@@ -118,10 +118,6 @@ class Request extends Common {
this.multipart = new Multipart(multipartAsValue)
}
Multipart getMultipart() {
return multipart
}
MatchingStrategy equalTo(Object value) {
return new MatchingStrategy(value, MatchingStrategy.Type.EQUAL_TO)
}