示例#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);
 }