use of org.mockserver.client.MockServerClient in project apm-agent-java by elastic.
the class MockServerContainer method containerIsStarted.
@Override
protected void containerIsStarted(InspectContainerResponse containerInfo) {
super.containerIsStarted(containerInfo);
client = new MockServerClient(getContainerIpAddress(), getFirstMappedPort());
}
use of org.mockserver.client.MockServerClient in project policies-ui-backend by RedHatInsights.
the class TestLifecycleManager method setupMockEngine.
void setupMockEngine(Map<String, String> props) {
mockEngineServer = new MockServerContainer();
// set up mock engine
mockEngineServer.start();
String mockServerUrl = "http://" + mockEngineServer.getContainerIpAddress() + ":" + mockEngineServer.getServerPort();
mockServerClient = new MockServerClient(mockEngineServer.getContainerIpAddress(), mockEngineServer.getServerPort());
mockRbac();
mockEngine();
props.put("quarkus.rest-client.engine.url", mockServerUrl);
props.put("quarkus.rest-client.rbac.url", mockServerUrl);
props.put("quarkus.rest-client.notifications.url", mockServerUrl);
}
use of org.mockserver.client.MockServerClient in project Insights by CognizantOneDevOps.
the class MockServerImpl method startMockServerWithExpectations.
/**
* This function will read all json files from getAllMockRequestsFromJson method
* and create expectations from the given Paths and Response in the individual
* tool's json.
*/
public void startMockServerWithExpectations() {
// Starting mock server on port 1080.
MockServerClient mockServer = startClientAndServer(1080);
// Reading mock requests from multiple JSON files.
List<MockRequest> mockRequests = getAllMockRequestsFromJson();
String response = null;
Iterator<MockRequest> mockIterator = mockRequests.iterator();
while (mockIterator.hasNext()) {
MockRequest request = mockIterator.next();
List<Parameter> parameterList = new ArrayList<>();
if (request.isResponseJson()) {
response = request.getResponse().get(0).toString();
} else {
response = request.getResponse().toString();
}
// checking if the request has any parameters.
if (request.getParameters() != null) {
for (Map.Entry<String, String> paramEntry : request.getParameters().entrySet()) {
Parameter param = new Parameter(paramEntry.getKey(), paramEntry.getValue());
parameterList.add(param);
}
}
// Creating mock Expectation
mockServer.when(request().withPath(request.getPath()).withQueryStringParameters(parameterList)).respond(response().withStatusCode(200).withBody(response));
log.debug("Expectation created for the path {} with query string parmeters {}", request.getPath(), parameterList);
}
log.info("Mock Server Started");
}
use of org.mockserver.client.MockServerClient in project dependency-track by DependencyTrack.
the class CsWebexPublisherTest method testPublish.
@Test
public void testPublish() {
new MockServerClient("localhost", 1080).when(request().withMethod("POST").withPath("/mychannel")).respond(response().withStatusCode(200).withHeader(HttpHeaders.CONTENT_TYPE, "application/json"));
JsonObject config = Json.createObjectBuilder().add("destination", "http://localhost:1080/mychannel").build();
Notification notification = new Notification();
notification.setScope(NotificationScope.PORTFOLIO.name());
notification.setGroup(NotificationGroup.NEW_VULNERABILITY.name());
notification.setLevel(NotificationLevel.INFORMATIONAL);
notification.setTitle("Test Notification");
notification.setContent("This is only a test");
CsWebexPublisher publisher = new CsWebexPublisher();
publisher.inform(notification, config);
}
use of org.mockserver.client.MockServerClient in project dependency-track by DependencyTrack.
the class WebhookPublisherTest method testPublish.
@Test
public void testPublish() {
new MockServerClient("localhost", 1080).when(request().withMethod("POST").withPath("/mychannel")).respond(response().withStatusCode(200).withHeader(HttpHeaders.CONTENT_TYPE, "application/json"));
JsonObject config = Json.createObjectBuilder().add("destination", "http://localhost:1080/mychannel").build();
Notification notification = new Notification();
notification.setScope(NotificationScope.PORTFOLIO.name());
notification.setGroup(NotificationGroup.NEW_VULNERABILITY.name());
notification.setLevel(NotificationLevel.INFORMATIONAL);
notification.setTitle("Test Notification");
notification.setContent("This is only a test");
WebhookPublisher publisher = new WebhookPublisher();
publisher.inform(notification, config);
}
Aggregations