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