private static Object[] expandVarArgs(final boolean isVarArgs, final Object[] args) {
if (!isVarArgs || args[args.length - 1] != null && !args[args.length - 1].getClass().isArray()) {
return args == null ? new Object[0] : args;
}
final int nonVarArgsCount = args.length - 1;
Object[] varArgs;
if (args[nonVarArgsCount] == null) {
// in case someone deliberately passed null varArg array
varArgs = new Object[] { null };
} else {
varArgs = ArrayEquals.createObjectArray(args[nonVarArgsCount]);
}
final int varArgsCount = varArgs.length;
Object[] newArgs = new Object[nonVarArgsCount + varArgsCount];
System.arraycopy(args, 0, newArgs, 0, nonVarArgsCount);
System.arraycopy(varArgs, 0, newArgs, nonVarArgsCount, varArgsCount);
return newArgs;
}
java类org.mockito.internal.matchers.ArrayEquals的实例源码
Invocation.java 文件源码
项目:astor
阅读 44
收藏 0
点赞 0
评论 0
ArgumentsProcessor.java 文件源码
项目:astor
阅读 31
收藏 0
点赞 0
评论 0
public static Object[] expandVarArgs(final boolean isVarArgs, final Object[] args) {
if (!isVarArgs || new ArrayUtils().isEmpty(args) || args[args.length - 1] != null && !args[args.length - 1].getClass().isArray()) {
return args == null ? new Object[0] : args;
}
final int nonVarArgsCount = args.length - 1;
Object[] varArgs;
if (args[nonVarArgsCount] == null) {
// in case someone deliberately passed null varArg array
varArgs = new Object[] { null };
} else {
varArgs = ArrayEquals.createObjectArray(args[nonVarArgsCount]);
}
final int varArgsCount = varArgs.length;
Object[] newArgs = new Object[nonVarArgsCount + varArgsCount];
System.arraycopy(args, 0, newArgs, 0, nonVarArgsCount);
System.arraycopy(varArgs, 0, newArgs, nonVarArgsCount, varArgsCount);
return newArgs;
}
RestHighLevelClientTests.java 文件源码
项目:elasticsearch_my
阅读 32
收藏 0
点赞 0
评论 0
@Override
public boolean matches(Object varargArgument) {
if (varargArgument instanceof Header[]) {
Header[] actualHeaders = (Header[]) varargArgument;
return new ArrayEquals(expectedHeaders).matches(actualHeaders);
}
return false;
}
TestZKProcedure.java 文件源码
项目:ditb
阅读 45
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:LCIndex-HBase-0.94.16
阅读 37
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:pbase
阅读 41
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:HIndex
阅读 33
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:IRIndex
阅读 48
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
Invocation.java 文件源码
项目:astor
阅读 36
收藏 0
点赞 0
评论 0
protected List<Matcher> argumentsToMatchers() {
List<Matcher> matchers = new ArrayList<Matcher>(arguments.length);
for (Object arg : arguments) {
if (arg != null && arg.getClass().isArray()) {
matchers.add(new ArrayEquals(arg));
} else {
matchers.add(new Equals(arg));
}
}
return matchers;
}
InvocationTest.java 文件源码
项目:astor
阅读 39
收藏 0
点赞 0
评论 0
@Test
public void shouldTransformArgumentsToMatchers() throws Exception {
Invocation i = new InvocationBuilder().args("foo", new String[] {"bar"}).toInvocation();
List matchers = i.argumentsToMatchers();
assertEquals(2, matchers.size());
assertEquals(Equals.class, matchers.get(0).getClass());
assertEquals(ArrayEquals.class, matchers.get(1).getClass());
}
ArgumentsProcessor.java 文件源码
项目:astor
阅读 33
收藏 0
点赞 0
评论 0
public static List<Matcher> argumentsToMatchers(Object[] arguments) {
List<Matcher> matchers = new ArrayList<Matcher>(arguments.length);
for (Object arg : arguments) {
if (arg != null && arg.getClass().isArray()) {
matchers.add(new ArrayEquals(arg));
} else {
matchers.add(new Equals(arg));
}
}
return matchers;
}
InvocationImplTest.java 文件源码
项目:astor
阅读 37
收藏 0
点赞 0
评论 0
@Test
public void shouldTransformArgumentsToMatchers() throws Exception {
Invocation i = new InvocationBuilder().args("foo", new String[]{"bar"}).toInvocation();
List matchers = ArgumentsProcessor.argumentsToMatchers(i.getArguments());
assertEquals(2, matchers.size());
assertEquals(Equals.class, matchers.get(0).getClass());
assertEquals(ArrayEquals.class, matchers.get(1).getClass());
}
TestZKProcedure.java 文件源码
项目:hbase
阅读 38
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:PyroDB
阅读 35
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:c5
阅读 31
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:HBase-Research
阅读 34
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:hbase-0.94.8-qod
阅读 37
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:hbase-0.94.8-qod
阅读 35
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
TestZKProcedure.java 文件源码
项目:hindex
阅读 34
收藏 0
点赞 0
评论 0
private void verifyCohortSuccessful(List<String> cohortNames,
SubprocedureFactory subprocFactory, Iterable<Subprocedure> cohortTasks,
VerificationMode prepare, VerificationMode commit, VerificationMode cleanup,
VerificationMode finish, boolean opHasError) throws Exception {
// make sure we build the correct number of cohort members
Mockito.verify(subprocFactory, Mockito.times(cohortNames.size())).buildSubprocedure(
Mockito.eq(opName), (byte[]) Mockito.argThat(new ArrayEquals(data)));
// verify that we ran each of the operations cleanly
int j = 0;
for (Subprocedure op : cohortTasks) {
LOG.debug("Checking mock:" + (j++));
waitAndVerifySubproc(op, prepare, commit, cleanup, finish, opHasError);
}
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 33
收藏 0
点赞 0
评论 0
/**
* Object array argument that is equal to the given array, i.e. it has to
* have the same type, length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param <T>
* the type of the array, it is passed through to prevent casts.
* @param value
* the given array.
* @return <code>null</code>.
*/
public static <T> T[] aryEq(T[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 38
收藏 0
点赞 0
评论 0
/**
* short array argument that is equal to the given array, i.e. it has to
* have the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static short[] aryEq(short[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 35
收藏 0
点赞 0
评论 0
/**
* long array argument that is equal to the given array, i.e. it has to have
* the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static long[] aryEq(long[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 44
收藏 0
点赞 0
评论 0
/**
* int array argument that is equal to the given array, i.e. it has to have
* the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static int[] aryEq(int[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 30
收藏 0
点赞 0
评论 0
/**
* float array argument that is equal to the given array, i.e. it has to
* have the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static float[] aryEq(float[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 43
收藏 0
点赞 0
评论 0
/**
* double array argument that is equal to the given array, i.e. it has to
* have the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static double[] aryEq(double[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 28
收藏 0
点赞 0
评论 0
/**
* char array argument that is equal to the given array, i.e. it has to have
* the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static char[] aryEq(char[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 36
收藏 0
点赞 0
评论 0
/**
* byte array argument that is equal to the given array, i.e. it has to have
* the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static byte[] aryEq(byte[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 37
收藏 0
点赞 0
评论 0
/**
* boolean array argument that is equal to the given array, i.e. it has to
* have the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static boolean[] aryEq(boolean[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 34
收藏 0
点赞 0
评论 0
/**
* Object array argument that is equal to the given array, i.e. it has to
* have the same type, length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param <T>
* the type of the array, it is passed through to prevent casts.
* @param value
* the given array.
* @return <code>null</code>.
*/
public static <T> T[] aryEq(T[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}
AdditionalMatchers.java 文件源码
项目:astor
阅读 29
收藏 0
点赞 0
评论 0
/**
* short array argument that is equal to the given array, i.e. it has to
* have the same length, and each element has to be equal.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given array.
* @return <code>null</code>.
*/
public static short[] aryEq(short[] value) {
return reportMatcher(new ArrayEquals(value)).returnNull();
}