本文整理匯總了Java中org.easymock.IArgumentMatcher類的典型用法代碼示例。如果您正苦於以下問題:Java IArgumentMatcher類的具體用法?Java IArgumentMatcher怎麽用?Java IArgumentMatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IArgumentMatcher類屬於org.easymock包,在下文中一共展示了IArgumentMatcher類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMatchers
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
/**
* Reports report reflection argument matchers for all arguments of the given method invocation.
* An exception will be thrown if there were already matchers reported for the invocation.
*
* @param invocation the method invocation, not null
*/
private void createMatchers(Invocation invocation) {
List<IArgumentMatcher> matchers = LastControl.pullMatchers();
if (matchers != null && !matchers.isEmpty()) {
if (matchers.size() != invocation.getArguments().length) {
throw new IllegalStateException("This mock control does not support mixing of no-argument matchers and per-argument matchers. " +
"Either no matchers are defined and the reflection argument matcher is used by default or all matchers are defined explicitly (Eg by using refEq()).");
}
// put all matchers back since pull removes them
for (IArgumentMatcher matcher : matchers) {
LastControl.reportMatcher(matcher);
}
return;
}
Object[] arguments = invocation.getArguments();
if (arguments == null) {
return;
}
for (Object argument : arguments) {
LastControl.reportMatcher(new ReflectionArgumentMatcher<Object>(argument, modes));
}
}
示例2: waypointEq
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
/**
* Waypoint equals.
*
* @param waypoint the waypoint
*/
private Waypoint waypointEq(final Waypoint waypoint) {
EasyMock.reportMatcher(new IArgumentMatcher() {
@Override
public boolean matches(Object object) {
if (object == null || waypoint == null) {
return waypoint == object;
}
Waypoint waypoint2 = (Waypoint) object;
return waypoint.getId() == waypoint2.getId();
}
@Override
public void appendTo(StringBuffer buffer) {
buffer.append("waypointEq(");
buffer.append(waypoint);
buffer.append(")");
}
});
return null;
}
示例3: trackEq
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
/**
* Track equals.
*
* @param track1 the track
*/
private Track trackEq(final Track track1) {
EasyMock.reportMatcher(new IArgumentMatcher() {
@Override
public boolean matches(Object object) {
if (object == null || track1 == null) {
return track1 == object;
}
Track track2 = (Track) object;
return track1.getName().equals(track2.getName());
}
@Override
public void appendTo(StringBuffer buffer) {
buffer.append("trackEq(");
buffer.append(track1);
buffer.append(")");
}
});
return null;
}
示例4: hasStatus
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
public static LocationUpdatedRemoteEvent hasStatus(final Status status) {
reportMatcher(new IArgumentMatcher() {
public void appendTo(StringBuffer buffer) {
buffer.append("hasStatus(\"" + status + "\")");
}
public boolean matches(Object argument) {
if (argument instanceof LocationUpdatedRemoteEvent) {
LocationUpdatedRemoteEvent e = (LocationUpdatedRemoteEvent)argument;
return status.equals(e.getLocationInfo().getStatus());
} else {
return false;
}
}
});
return null;
}
示例5: is
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
private <T> T is(final RequestMatcher matcher)
{
reportMatcher(new IArgumentMatcher() {
public boolean matches(Object argument) {
try {
matcher.match(null, serialize(argument));
} catch (IOException e) {
throw new IllegalArgumentException("Can not match the request.",e);
}
return true;
}
public void appendTo(StringBuffer buffer) {
}
});
return null;
}
示例6: classEq
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
public static Exception classEq(final Class<? extends Exception> in) {
EasyMock.reportMatcher(new IArgumentMatcher() {
@Override
public void appendTo(StringBuffer buffer) {
buffer.append("classEq(");
buffer.append(in);
buffer.append(")");
}
@Override
public boolean matches(Object arg) {
return arg.getClass() == in;
}
});
return null;
}
示例7: locationEq
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
/**
* Location equals.
*
* @param location the location
*/
private Location locationEq(final Location location) {
EasyMock.reportMatcher(new IArgumentMatcher() {
@Override
public boolean matches(Object object) {
if (object == null || location == null) {
return location == object;
}
Location location2 = (Location) object;
return location.hasAccuracy() == location2.hasAccuracy()
&& (!location.hasAccuracy() || location.getAccuracy() == location2.getAccuracy())
&& location.hasAltitude() == location2.hasAltitude()
&& (!location.hasAltitude() || location.getAltitude() == location2.getAltitude())
&& location.hasBearing() == location2.hasBearing()
&& (!location.hasBearing() || location.getBearing() == location2.getBearing())
&& location.hasSpeed() == location2.hasSpeed()
&& (!location.hasSpeed() || location.getSpeed() == location2.getSpeed())
&& location.getLatitude() == location2.getLatitude()
&& location.getLongitude() == location2.getLongitude()
&& location.getTime() == location2.getTime();
}
@Override
public void appendTo(StringBuffer buffer) {
buffer.append("locationEq(");
buffer.append(location);
buffer.append(")");
}
});
return null;
}
示例8: eqRegion
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
private static com.amazonaws.regions.Region eqRegion(final com.amazonaws.regions.Region region) {
EasyMock.reportMatcher(new IArgumentMatcher() {
@Override
public boolean matches(Object o) {
com.amazonaws.regions.Region givenRegion = (com.amazonaws.regions.Region) o;
return givenRegion.getName().equals(region.getName());
}
@Override
public void appendTo(StringBuffer stringBuffer) {
stringBuffer.append("eqReqion for ").append(region.getName());
}
});
return region;
}
示例9: eqLoc
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
public static Location[] eqLoc(Location[] expected) {
IArgumentMatcher matcher = new LocationsMatcher(expected);
AndroidMock.reportMatcher(matcher);
return null;
}
示例10: reportMatcher
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
/**
* Reports an argument matcher. This method is needed to define custom argument
* matchers.
*
* For example:
*
* {@code
* AndroidMock.reportMatcher(new IntIsFortyTwo());
* AndroidMock.expect(mockObject.getString(null)).andReturn("hello world");}
*
* This example will expect a parameter for {@code mockObject.getString(int)} that matches the
* conditions required by the {@code matches} method as defined by
* {@link org.easymock.IArgumentMatcher#matches(Object)}.
*
* @param matcher the matcher whose {@code matches} method will be applied to the incoming
* parameter to the mocked method.
*/
public static void reportMatcher(IArgumentMatcher matcher) {
EasyMock.reportMatcher(matcher);
}
示例11: reportMatcher
import org.easymock.IArgumentMatcher; //導入依賴的package包/類
/**
* Reports an argument matcher. This method is needed to define own argument
* matchers. For details, see the EasyMock documentation.
*
* @param matcher
*/
protected final void reportMatcher(final IArgumentMatcher matcher) {
EasyMock.reportMatcher(matcher);
}