Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2011 Thomas Akehurst
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.tomakehurst.wiremock.admin;
import com.github.tomakehurst.wiremock.http.RequestMethod;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import static com.github.tomakehurst.wiremock.admin.RequestSpec.requestSpec;
import static com.github.tomakehurst.wiremock.common.Exceptions.throwUnchecked;
import static com.github.tomakehurst.wiremock.http.RequestMethod.GET;
import static com.github.tomakehurst.wiremock.http.RequestMethod.POST;
public class AdminTasks {
private static final BiMap> TASKS =
new ImmutableBiMap.Builder>()
.put(requestSpec(GET, "/"), RootTask.class)
.put(requestSpec(GET, ""), RootRedirectTask.class)
.put(requestSpec(POST, "/reset"), ResetTask.class)
.put(requestSpec(POST, "/mappings/new"), StubMappingTask.class)
.put(requestSpec(POST, "/mappings/remove"), RemoveStubMappingTask.class)
.put(requestSpec(POST, "/mappings/edit"), EditStubMappingTask.class)
.put(requestSpec(POST, "/scenarios/reset"), ResetScenariosTask.class)
.put(requestSpec(POST, "/mappings/save"), SaveMappingsTask.class)
.put(requestSpec(POST, "/mappings/reset"), ResetToDefaultMappingsTask.class)
.put(requestSpec(POST, "/requests/reset"), ResetRequestsTask.class)
.put(requestSpec(POST, "/requests/count"), GetRequestCountTask.class)
.put(requestSpec(POST, "/requests/find"), FindRequestsTask.class)
.put(requestSpec(GET, "/requests/unmatched"), FindUnmatchedRequestsTask.class)
.put(requestSpec(GET, "/requests/unmatched/near-misses"), FindNearMissesForUnmatchedTask.class)
.put(requestSpec(POST, "/near-misses/request"), FindNearMissesForRequestTask.class)
.put(requestSpec(POST, "/near-misses/request-pattern"), FindNearMissesForRequestPatternTask.class)
.put(requestSpec(POST, "/settings"), GlobalSettingsUpdateTask.class)
.put(requestSpec(POST, "/shutdown"), ShutdownServerTask.class)
.build();
public static AdminTask taskFor(RequestMethod method, String path) {
Class taskClass = TASKS.get(requestSpec(method, path));
if (taskClass == null) {
return new NotFoundAdminTask();
}
try {
return taskClass.newInstance();
} catch (Exception e) {
return throwUnchecked(e, AdminTask.class);
}
}
public static RequestSpec requestSpecForTask(Class taskClass) {
return TASKS.inverse().get(taskClass);
}
}