예제 #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);
 }