HttpClient.HttpRequest requestContainingFunctionId(String functionId) {
ArgumentMatcher<HttpClient.HttpRequest> argumentMatcher = httpRequest -> {
if(httpRequest.method != "POST") {
System.err.println("Expecting a POST request,got " + httpRequest.method);
return false;
}
try {
APIModel.CreateGraphRequest createGraphRequest = objectMapper.readValue(new String(httpRequest.bodyBytes),APIModel.CreateGraphRequest.class);
if ((createGraphRequest.functionId != null) && (createGraphRequest.functionId.equals(functionId))) {
return true;
}
System.err.println("Request body doesn't contain an CreateGraphRequest with matching functionId field");
return false;
} catch (IOException e) {
System.err.println("Request body doesn't contain an CreateGraphRequest");
return false;
}
};
ThreadSafeMockingProgress.mockingProgress().getArgumentMatcherStorage().reportMatcher(argumentMatcher);
return null;
}
HttpClient.HttpRequest requestContainingAddStageRequest(String blobId,List<String> dependencies) {
ArgumentMatcher<HttpClient.HttpRequest> argumentMatcher = httpRequest -> {
if(httpRequest.method != "POST") {
System.err.println("Expecting a POST request,got " + httpRequest.method);
return false;
}
try {
APIModel.AddStageRequest addStageRequest = objectMapper.readValue(new String(httpRequest.bodyBytes),APIModel.AddStageRequest.class);
if ( (addStageRequest.closure != null) &&
(addStageRequest.closure.blobId.equals(blobId)) &&
(addStageRequest.deps.equals(dependencies))) {
return true;
}
System.err.println("Request body doesn't contain an AddStageRequest with closure with matching blobId field");
return false;
} catch (IOException e) {
System.err.println("Request body doesn't contain an AddStageRequest");
return false;
}
};
ThreadSafeMockingProgress.mockingProgress().getArgumentMatcherStorage().reportMatcher(argumentMatcher);
return null;
}
HttpClient.HttpRequest requestContainingAddInvokeFunctionStageRequest(String functionId,APIModel.HTTPMethod httpMethod) {
ArgumentMatcher<HttpClient.HttpRequest> argumentMatcher = httpRequest -> {
if(httpRequest.method != "POST") {
System.err.println("Expecting a POST request,got " + httpRequest.method);
return false;
}
try {
APIModel.AddInvokeFunctionStageRequest addInvokeFunctionStageRequest = objectMapper.readValue(new String(httpRequest.bodyBytes),APIModel.AddInvokeFunctionStageRequest.class);
if ((addInvokeFunctionStageRequest.functionId != null) &&
(addInvokeFunctionStageRequest.functionId.equals(functionId)) &&
(addInvokeFunctionStageRequest.arg.method.equals(httpMethod))) {
return true;
} else {
System.err.println("Request body doesn't contain a matching AddInvokeFunctionStageRequest");
}
return false;
} catch (IOException e) {
System.err.println("Request body doesn't contain an AddInvokeFunctionStageRequest");
return false;
}
};
ThreadSafeMockingProgress.mockingProgress().getArgumentMatcherStorage().reportMatcher(argumentMatcher);
return null;
}
项目:morf
文件:InjectMembersRule.java
/**
* @see org.junit.rules.MethodRule#apply(org.junit.runners.model.Statement,org.junit.runners.model.FrameworkMethod,java.lang.Object)
*/
@Override
public Statement apply(final Statement base,final FrameworkMethod method,final Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final List<Module> moduleWithTarget = new ArrayList<>(Arrays.asList(modules));
if (target instanceof Module) {
moduleWithTarget.add((Module) target);
}
Guice.createInjector(moduleWithTarget).injectMembers(target);
try {
base.evaluate();
} finally {
new ThreadSafeMockingProgress().reset();
}
}
};
}
HttpClient.HttpRequest requestForAwaitStageResult() {
ArgumentMatcher<HttpClient.HttpRequest> argumentMatcher = httpRequest -> {
if(httpRequest.method != "GET") {
System.err.println("Expecting a GET request,got " + httpRequest.method);
return false;
}
return true;
};
ThreadSafeMockingProgress.mockingProgress().getArgumentMatcherStorage().reportMatcher(argumentMatcher);
return null;
}
项目:powermock
文件:MockitoMethodInvocationControl.java
private VerificationMode getVerificationMode() {
try {
MockingProgress progress = (MockingProgress) WhiteBox.invokeMethod(ThreadSafeMockingProgress.class,"threadSafely");
return getVerificationModeFromMockProgress(progress);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
项目:powermock
文件:MockitoMethodInvocationControl.java
@SuppressWarnings("unchecked")
private VerificationMode getVerificationModeFromMockProgress(MockingProgress mockingProgress) {
if (mockingProgress == null) {
return null;
}
if (mockingProgress instanceof ThreadSafeMockingProgress) {
ThreadLocal<MockingProgress> threadLocal = WhiteBox.getInternalState(mockingProgress,ThreadLocal.class);
return getVerificationModeFromMockProgress(threadLocal.get());
} else {
Localized<VerificationMode> verificationMode = WhiteBox.getInternalState(mockingProgress,Localized.class);
return verificationMode == null ? null : verificationMode.getobject();
}
}
项目:astor
文件:MockitoTest.java
项目:empiria.player
文件:MocksCollector.java
public MocksCollector() {
createdMocks = new LinkedList<Object>();
final MockingProgress progress = new ThreadSafeMockingProgress();
progress.setListener(new CollectCreatedMocks(createdMocks));
}
项目:powermock
文件:MockitoStateCleaner.java
void clearMockProgress() {
clearThreadLocalIn(ThreadSafeMockingProgress.class);
}
项目:spring-batch
文件:MocksCollector.java
public MocksCollector() {
createdMocks = new LinkedList<>();
final MockingProgress progress = new ThreadSafeMockingProgress();
progress.setListener(new CollectCreatedMocks(createdMocks));
}
项目:astor
文件:MockHandler.java
public MockHandler(MockSettingsImpl mockSettings) {
this.mockSettings = mockSettings;
this.mockingProgress = new ThreadSafeMockingProgress();
this.matchersBinder = new MatchersBinder();
this.invocationContainerImpl = new InvocationContainerImpl(mockingProgress);
}
项目:astor
文件:WarningsCollector.java
public WarningsCollector() {
createdMocks = new LinkedList();
MockingProgress progress = new ThreadSafeMockingProgress();
progress.setListener(new CollectCreatedMocks(createdMocks));
}
项目:astor
文件:MockHandlerImpl.java
public MockHandlerImpl(MockCreationSettings mockSettings) {
this.mockSettings = mockSettings;
this.mockingProgress = new ThreadSafeMockingProgress();
this.matchersBinder = new MatchersBinder();
this.invocationContainerImpl = new InvocationContainerImpl(mockingProgress,mockSettings);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。