/** * Creates an {@link org.hamcrest.core.IsEqual} matcher that does not enforce the values being * compared to be of the same static type. */ public static Matcher<Object> equalToObject(Object operand) { return new IsEqual<>(operand); } }
/** * Creates a matcher that matches when the examined object is logically equal to the specified * <code>operand</code>, as determined by calling the {@link java.lang.Object#equals} method on * the <b>examined</b> object. * * <p>If the specified operand is <code>null</code> then the created matcher will only match if * the examined object's <code>equals</code> method returns <code>true</code> when passed a * <code>null</code> (which would be a violation of the <code>equals</code> contract), unless the * examined object itself is <code>null</code>, in which case the matcher will return a positive * match.</p> * * <p>The created matcher provides a special behaviour when examining <code>Array</code>s, whereby * it will match if both the operand and the examined object are arrays of the same length and * contain items that are equal to each other (according to the above rules) <b>in the same * indexes</b>.</p> * For example: * <pre> * assertThat("foo", equalTo("foo")); * assertThat(new String[] {"foo", "bar"}, equalTo(new String[] {"foo", "bar"})); * </pre> * */ public static <T> Matcher<T> equalTo(T operand) { return new IsEqual<>(operand); }
/** * Creates a matcher that matches when the examined object is logically equal to the specified * <code>operand</code>, as determined by calling the {@link java.lang.Object#equals} method on * the <b>examined</b> object. * * <p>If the specified operand is <code>null</code> then the created matcher will only match if * the examined object's <code>equals</code> method returns <code>true</code> when passed a * <code>null</code> (which would be a violation of the <code>equals</code> contract), unless the * examined object itself is <code>null</code>, in which case the matcher will return a positive * match.</p> * * <p>The created matcher provides a special behaviour when examining <code>Array</code>s, whereby * it will match if both the operand and the examined object are arrays of the same length and * contain items that are equal to each other (according to the above rules) <b>in the same * indexes</b>.</p> * <p/> * For example: * <pre> * assertThat("foo", equalTo("foo")); * assertThat(new String[] {"foo", "bar"}, equalTo(new String[] {"foo", "bar"})); * </pre> * */ @Factory public static <T> Matcher<T> equalTo(T operand) { return new IsEqual<T>(operand); } }
/** * Creates a matcher that matches when the examined object is logically equal to the specified * <code>operand</code>, as determined by calling the {@link java.lang.Object#equals} method on * the <b>examined</b> object. * * <p>If the specified operand is <code>null</code> then the created matcher will only match if * the examined object's <code>equals</code> method returns <code>true</code> when passed a * <code>null</code> (which would be a violation of the <code>equals</code> contract), unless the * examined object itself is <code>null</code>, in which case the matcher will return a positive * match.</p> * * <p>The created matcher provides a special behaviour when examining <code>Array</code>s, whereby * it will match if both the operand and the examined object are arrays of the same length and * contain items that are equal to each other (according to the above rules) <b>in the same * indexes</b>.</p> * <p/> * For example: * <pre> * assertThat("foo", equalTo("foo")); * assertThat(new String[] {"foo", "bar"}, equalTo(new String[] {"foo", "bar"})); * </pre> * */ @Factory public static <T> Matcher<T> equalTo(T operand) { return new IsEqual<T>(operand); } }
public void testCanMatchItemWhenCollectionHoldsSuperclass() // Issue 24 { final Set<Number> s = new HashSet<Number>(); s.add(Integer.valueOf(2)); assertThat(s, new IsCollectionContaining<Number>(new IsEqual<Number>(Integer.valueOf(2)))); assertThat(s, IsCollectionContaining.hasItem(Integer.valueOf(2))); }
@Test public void canMatchItemWhenCollectionHoldsSuperclass() { // Issue 24 final Set<Number> s = new HashSet<>(); s.add(2); assertMatches(new IsIterableContaining<>(new IsEqual<Number>(2)), s); assertMatches(IsIterableContaining.hasItem(2), s); }
/** * Creates an {@link org.hamcrest.core.IsEqual} matcher that does not enforce the values being * compared to be of the same static type. */ public static Matcher<Object> equalToObject(Object operand) { return new IsEqual<Object>(operand); } }
/** * Creates a matcher that matches when the examined object is logically equal to the specified * <code>operand</code>, as determined by calling the {@link java.lang.Object#equals} method on * the <b>examined</b> object. * * <p>If the specified operand is <code>null</code> then the created matcher will only match if * the examined object's <code>equals</code> method returns <code>true</code> when passed a * <code>null</code> (which would be a violation of the <code>equals</code> contract), unless the * examined object itself is <code>null</code>, in which case the matcher will return a positive * match.</p> * * <p>The created matcher provides a special behaviour when examining <code>Array</code>s, whereby * it will match if both the operand and the examined object are arrays of the same length and * contain items that are equal to each other (according to the above rules) <b>in the same * indexes</b>.</p> * For example: * <pre> * assertThat("foo", equalTo("foo")); * assertThat(new String[] {"foo", "bar"}, equalTo(new String[] {"foo", "bar"})); * </pre> * */ public static <T> Matcher<T> equalTo(T operand) { return new IsEqual<T>(operand); }
@Test public void testCombiner() throws Exception { org.junit.Assume.assumeThat(mode, new IsEqual<TestExecutionMode>(TestExecutionMode.CLUSTER)); final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple2<IntWritable, IntWritable>> ds = HadoopTestData.getKVPairDataSet(env). map(new Mapper3()); DataSet<Tuple2<IntWritable, IntWritable>> counts = ds. groupBy(0). reduceGroup(new HadoopReduceCombineFunction<IntWritable, IntWritable, IntWritable, IntWritable>( new SumReducer(), new KeyChangingReducer())); String resultPath = tempFolder.newFile().toURI().toString(); counts.writeAsText(resultPath); env.execute(); String expected = "(0,5)\n" + "(1,6)\n" + "(2,5)\n" + "(3,5)\n"; compareResultsByLinesInMemory(expected, resultPath); }
/** * Creates a matcher that matches when the examined object is logically equal to the specified * <code>operand</code>, as determined by calling the {@link java.lang.Object#equals} method on * the <b>examined</b> object. * * <p>If the specified operand is <code>null</code> then the created matcher will only match if * the examined object's <code>equals</code> method returns <code>true</code> when passed a * <code>null</code> (which would be a violation of the <code>equals</code> contract), unless the * examined object itself is <code>null</code>, in which case the matcher will return a positive * match.</p> * * <p>The created matcher provides a special behaviour when examining <code>Array</code>s, whereby * it will match if both the operand and the examined object are arrays of the same length and * contain items that are equal to each other (according to the above rules) <b>in the same * indexes</b>.</p> * <p/> * For example: * <pre> * assertThat("foo", equalTo("foo")); * assertThat(new String[] {"foo", "bar"}, equalTo(new String[] {"foo", "bar"})); * </pre> * */ @Factory public static <T> Matcher<T> equalTo(T operand) { return new IsEqual<T>(operand); } }
/** * Constructor taking String. * * @param path The mandatory argument is the path which will be listened on */ public ClientDriverRequest(String path) { this(new IsEqual<String>(path)); }
/** * Constructor taking String. * * @param path The mandatory argument is the path which will be listened on */ public ClientDriverRequest(String path) { this(new IsEqual<String>(path)); }
@SuppressWarnings("unchecked") private static Matcher<Object>[] equalMatchersFor(Object[] expectedValues) { Matcher<Object>[] matchers = new Matcher[expectedValues.length]; for (int i = 0; i < expectedValues.length; i++) { matchers[i] = new IsEqual<Object>(expectedValues[i]); } return matchers; }
/** * Ctor. * @param result The result expected * @param inpt Input for the function */ public FuncApplies(final X inpt, final Y result) { this(inpt, new IsEqual<>(result)); }
/** * Creates an {@link org.hamcrest.core.IsEqual} matcher that does not enforce the values being * compared to be of the same static type. */ public static Matcher<Object> equalToObject(Object operand) { return new IsEqual<>(operand); } }
/** * Is the value equal to another value, as tested by the * {@link java.lang.Object#equals} invokedMethod? */ @Factory public static <T> Matcher<T> equalTo(T operand) { return new IsEqual<T>(operand); }
/** * Setter for expecting query-string parameters on the end of the url. * * @param key The key from ?key=value * @param value The value from ?key=value in the form of a String * @return the object you called the method on, so you can chain these calls. */ public ClientDriverRequest withParam(String key, String value) { params.put(key, new IsEqual<String>(value)); return this; }
/** * Setter for expecting query-string parameters on the end of the url. * * @param key The key from ?key=value * @param value The value from ?key=value in the form of a String * @return the object you called the method on, so you can chain these calls. */ public ClientDriverRequest withParam(String key, String value) { params.put(key, new IsEqual<String>(value)); return this; }
/** * Setter for expecting a specific header name and value pair. * * @param withHeaderName the headerName to match on * @param withHeaderValue the headerValue to match on * @return the object you called the method on, so you can chain these calls */ public ClientDriverRequest withHeader(String withHeaderName, String withHeaderValue) { return withHeader(withHeaderName, new IsEqual<String>(withHeaderValue)); }
/** * Setter for expecting a specific header name and value pair. * * @param withHeaderName the headerName to match on * @param withHeaderValue the headerValue to match on * @return the object you called the method on, so you can chain these calls */ public ClientDriverRequest withHeader(String withHeaderName, String withHeaderValue) { return withHeader(withHeaderName, new IsEqual<String>(withHeaderValue)); }