Пример #1
0
 @Override
 public SingleServedStubResult getServedStub(UUID id) {
   return executeRequest(
       adminRoutes.requestSpecForTask(GetServedStubTask.class),
       PathParams.single("id", id),
       SingleServedStubResult.class);
 }
Пример #2
0
 @Override
 @SuppressWarnings("unchecked")
 public SingleStubMappingResult getStubMapping(UUID id) {
   return executeRequest(
       adminRoutes.requestSpecForTask(GetStubMappingTask.class),
       PathParams.single("id", id),
       SingleStubMappingResult.class);
 }
Пример #3
0
  public HttpAdminClient(
      String scheme, String host, int port, String urlPathPrefix, String hostHeader) {
    this.scheme = scheme;
    this.host = host;
    this.port = port;
    this.urlPathPrefix = urlPathPrefix;
    this.hostHeader = hostHeader;

    adminRoutes = AdminRoutes.defaults();

    httpClient = HttpClientFactory.createClient();
  }
Пример #4
0
  @Override
  public void addStubMapping(StubMapping stubMapping) {
    if (stubMapping.getRequest().hasCustomMatcher()) {
      throw new AdminException(
          "Custom matchers can't be used when administering a remote WireMock server. "
              + "Use WireMockRule.stubFor() or WireMockServer.stubFor() to administer the local instance.");
    }

    executeRequest(
        adminRoutes.requestSpecForTask(CreateStubMappingTask.class),
        PathParams.empty(),
        stubMapping,
        Void.class,
        201);
  }
Пример #5
0
 private String urlFor(Class<? extends AdminTask> taskClass) {
   RequestSpec requestSpec = adminRoutes.requestSpecForTask(taskClass);
   checkNotNull(requestSpec, "No admin task URL is registered for " + taskClass.getSimpleName());
   return String.format(ADMIN_URL_PREFIX + requestSpec.path(), scheme, host, port, urlPathPrefix);
 }
Пример #6
0
 @Override
 public GetServeEventsResult getServeEvents() {
   return executeRequest(
       adminRoutes.requestSpecForTask(GetAllRequestsTask.class), GetServeEventsResult.class);
 }
Пример #7
0
 @Override
 public void resetMappings() {
   executeRequest(adminRoutes.requestSpecForTask(ResetStubMappingsTask.class));
 }
Пример #8
0
 @Override
 public void resetScenarios() {
   executeRequest(adminRoutes.requestSpecForTask(ResetScenariosTask.class));
 }
Пример #9
0
 @Override
 public ListStubMappingsResult listAllStubMappings() {
   return executeRequest(
       adminRoutes.requestSpecForTask(GetAllStubMappingsTask.class), ListStubMappingsResult.class);
 }