Esempio n. 1
0
 @Override
 public SingleServedStubResult getServedStub(UUID id) {
   return executeRequest(
       adminRoutes.requestSpecForTask(GetServedStubTask.class),
       PathParams.single("id", id),
       SingleServedStubResult.class);
 }
Esempio n. 2
0
 @Override
 @SuppressWarnings("unchecked")
 public SingleStubMappingResult getStubMapping(UUID id) {
   return executeRequest(
       adminRoutes.requestSpecForTask(GetStubMappingTask.class),
       PathParams.single("id", id),
       SingleStubMappingResult.class);
 }
Esempio n. 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();
  }
Esempio n. 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);
  }
Esempio n. 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);
 }
Esempio n. 6
0
 @Override
 public GetServeEventsResult getServeEvents() {
   return executeRequest(
       adminRoutes.requestSpecForTask(GetAllRequestsTask.class), GetServeEventsResult.class);
 }
Esempio n. 7
0
 @Override
 public void resetMappings() {
   executeRequest(adminRoutes.requestSpecForTask(ResetStubMappingsTask.class));
 }
Esempio n. 8
0
 @Override
 public void resetScenarios() {
   executeRequest(adminRoutes.requestSpecForTask(ResetScenariosTask.class));
 }
Esempio n. 9
0
 @Override
 public ListStubMappingsResult listAllStubMappings() {
   return executeRequest(
       adminRoutes.requestSpecForTask(GetAllStubMappingsTask.class), ListStubMappingsResult.class);
 }