Add mock list
This commit is contained in:
parent
88bb4f3067
commit
ba63d36fa0
7 changed files with 120 additions and 14 deletions
|
@ -2,6 +2,7 @@ package pl.touk.mockserver.client
|
|||
|
||||
import groovy.util.slurpersupport.GPathResult
|
||||
import org.apache.http.client.methods.CloseableHttpResponse
|
||||
import org.apache.http.client.methods.HttpGet
|
||||
import org.apache.http.client.methods.HttpPost
|
||||
import org.apache.http.entity.ContentType
|
||||
import org.apache.http.entity.StringEntity
|
||||
|
@ -64,4 +65,14 @@ class ControlServerClient {
|
|||
</addMock>
|
||||
""", ContentType.create("text/xml", "UTF-8"))
|
||||
}
|
||||
|
||||
List<RegisteredMock> listMocks() {
|
||||
HttpGet get = new HttpGet(address)
|
||||
CloseableHttpResponse response = client.execute(get)
|
||||
GPathResult xml = Util.extractXmlResponse(response)
|
||||
if(xml.name() == 'mocks'){
|
||||
return xml.mock.collect {new RegisteredMock(it.name.text(), it.path.text(), it.port.text() as int)}
|
||||
}
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package pl.touk.mockserver.client
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.EqualsAndHashCode
|
||||
import groovy.transform.TypeChecked
|
||||
|
||||
@CompileStatic
|
||||
@TypeChecked
|
||||
@EqualsAndHashCode
|
||||
class RegisteredMock {
|
||||
final String name
|
||||
final String path
|
||||
final int port
|
||||
|
||||
RegisteredMock(String name, String path, int port) {
|
||||
this.name = name
|
||||
this.path = path
|
||||
this.port = port
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue