How to use Matches class of org.easymock.internal.matchers package

Best Easymock code snippet using org.easymock.internal.matchers.Matches

Source:ExpectedInvocation.java Github

copy

Full Screen

1/*2 * Copyright 2001-2009 OFFIS, Tammo Freese3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package org.easymock.internal;1718import java.io.Serializable;19import java.lang.reflect.Method;20import java.util.ArrayList;21import java.util.Iterator;22import java.util.List;2324import org.easymock.IArgumentMatcher;25import org.easymock.internal.matchers.Equals;2627public class ExpectedInvocation implements Serializable {2829 private static final long serialVersionUID = -5554816464613350531L;3031 private final Invocation invocation;3233 @SuppressWarnings("deprecation")34 private final org.easymock.ArgumentsMatcher matcher;3536 private final List<IArgumentMatcher> matchers;3738 public ExpectedInvocation(Invocation invocation,39 List<IArgumentMatcher> matchers) {40 this(invocation, matchers, null);41 }4243 private ExpectedInvocation(Invocation invocation,44 List<IArgumentMatcher> matchers, @SuppressWarnings("deprecation")45 org.easymock.ArgumentsMatcher matcher) {46 this.invocation = invocation;47 this.matcher = matcher;48 this.matchers = (matcher == null) ? createMissingMatchers(invocation,49 matchers) : null;50 }5152 private List<IArgumentMatcher> createMissingMatchers(Invocation invocation,53 List<IArgumentMatcher> matchers) {54 if (matchers != null) {55 if (matchers.size() != invocation.getArguments().length) {56 throw new IllegalStateException(""57 + invocation.getArguments().length58 + " matchers expected, " + matchers.size()59 + " recorded.");60 }61 return matchers;62 }63 List<IArgumentMatcher> result = new ArrayList<IArgumentMatcher>();64 for (Object argument : invocation.getArguments()) {65 result.add(new Equals(argument));66 }67 return result;68 }6970 @Override71 public boolean equals(Object o) {72 if (o == null || !this.getClass().equals(o.getClass()))73 return false;7475 ExpectedInvocation other = (ExpectedInvocation) o;76 return this.invocation.equals(other.invocation)77 && ((this.matcher == null && other.matcher == null) || (this.matcher != null && this.matcher78 .equals(other.matcher)))79 && ((this.matchers == null && other.matchers == null) || (this.matchers != null && this.matchers80 .equals(other.matchers)));81 }8283 @Override84 public int hashCode() {85 throw new UnsupportedOperationException("hashCode() is not implemented");86 }8788 public boolean matches(Invocation actual) {89 return matchers != null ? this.invocation.getMock().equals(90 actual.getMock())91 && this.invocation.getMethod().equals(actual.getMethod())92 && matches(actual.getArguments()) : this.invocation.matches(93 actual, matcher);94 }9596 private boolean matches(Object[] arguments) {97 if (arguments.length != matchers.size()) {98 return false;99 }100 for (int i = 0; i < arguments.length; i++) {101 if (!matchers.get(i).matches(arguments[i])) {102 return false;103 }104 }105 return true;106 }107108 @Override109 public String toString() {110 return matchers != null ? myToString() : invocation.toString(matcher);111 }112113 private String myToString() {114 StringBuffer result = new StringBuffer();115 result.append(invocation.getMockAndMethodName());116 result.append("(");117 for (Iterator<IArgumentMatcher> it = matchers.iterator(); it.hasNext();) {118 it.next().appendTo(result);119 if (it.hasNext()) {120 result.append(", ");121 }122 }123 result.append(")");124 return result.toString();125 }126127 public Method getMethod() {128 return invocation.getMethod();129 }130131 public ExpectedInvocation withMatcher(@SuppressWarnings("deprecation")132 org.easymock.ArgumentsMatcher matcher) {133 return new ExpectedInvocation(invocation, null, matcher);134 }135} ...

Full Screen

Full Screen

Matches

Using AI Code Generation

copy

Full Screen

1Matcher<String> m = new Matches(".*easymock.*");2Matcher<String> m = new Matches(".*easymock.*");3Matcher<String> m = new Matches(".*easymock.*");4Matcher<String> m = new Matches(".*easymock.*");5Matcher<String> m = new Matches(".*easymock.*");6Matcher<String> m = new Matches(".*easymock.*");7Matcher<String> m = new Matches(".*easymock.*");8Matcher<String> m = new Matches(".*easymock.*");9Matcher<String> m = new Matches(".*easymock.*");10Matcher<String> m = new Matches(".*easymock.*");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Easymock automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in Matches

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful