Package no.digipost.api.client.testing
Class DigipostClientMock
- java.lang.Object
-
- no.digipost.api.client.testing.DigipostClientMock
-
public class DigipostClientMock extends java.lang.Object
Instansierer en DigipostClient som ikke går mot faktiskt Digipost REST-api endepunkt og som kan brukes av tester o.l for å framprovosere ulike feilsituasjoner.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DigipostClientMock.ValidatingMarshaller
Threadsafe instance for marshalling and validating.
-
Field Summary
Fields Modifier and Type Field Description java.util.Map<DigipostApiMock.Method,DigipostApiMock.RequestsAndResponses>
requestsAndResponsesMap
-
Constructor Summary
Constructors Constructor Description DigipostClientMock()
DigipostClientMock(java.util.function.UnaryOperator<no.digipost.http.client3.DigipostHttpClientSettings> clientCustomizer)
-
Method Summary
Modifier and Type Method Description void
addExpectedException(DigipostApiMock.Method method, java.lang.RuntimeException exception)
void
addExpectedResponse(DigipostApiMock.Method method, org.apache.http.client.methods.CloseableHttpResponse response)
java.util.Map<java.lang.String,DigipostApiMock.MockRequest>
getAllRequests(DigipostApiMock.Method method)
DigipostClient
getClient()
static java.security.KeyPair
getKeyPair(java.lang.String alias, java.lang.String password)
DigipostApiMock.MockRequest
getRequest(DigipostApiMock.Method method, java.lang.String requestKey)
static DigipostClientMock.ValidatingMarshaller
initMarshaller()
Used to validate that requests are according to XSDvoid
reset()
void
shutdownWebserver()
void
start()
-
-
-
Field Detail
-
requestsAndResponsesMap
public final java.util.Map<DigipostApiMock.Method,DigipostApiMock.RequestsAndResponses> requestsAndResponsesMap
-
-
Method Detail
-
start
public void start()
-
getKeyPair
public static java.security.KeyPair getKeyPair(java.lang.String alias, java.lang.String password)
-
shutdownWebserver
public void shutdownWebserver()
-
getClient
public DigipostClient getClient()
-
getAllRequests
public java.util.Map<java.lang.String,DigipostApiMock.MockRequest> getAllRequests(DigipostApiMock.Method method)
-
getRequest
public DigipostApiMock.MockRequest getRequest(DigipostApiMock.Method method, java.lang.String requestKey)
-
addExpectedResponse
public void addExpectedResponse(DigipostApiMock.Method method, org.apache.http.client.methods.CloseableHttpResponse response)
-
addExpectedException
public void addExpectedException(DigipostApiMock.Method method, java.lang.RuntimeException exception)
-
reset
public void reset()
-
initMarshaller
public static DigipostClientMock.ValidatingMarshaller initMarshaller()
Used to validate that requests are according to XSD
-
-