类org.mockito.internal.matchers.apachecommons.ReflectionEquals源码实例Demo

下面列出了怎么用org.mockito.internal.matchers.apachecommons.ReflectionEquals的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: sharding-jdbc-1.5.1   文件: TokenizerTest.java
@Test
public void assertScanNChars() {
    String sql = "SELECT * FROM ORDER, XX_TABLE AS `table` WHERE YY=N'xx' And group =-1 GROUP BY YY";
    Tokenizer tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("ORDER"));
    assertTrue(new ReflectionEquals(tokenizer.scanIdentifier()).matches(new Token(Literals.IDENTIFIER, "ORDER", sql.indexOf(","))));
    tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("GROUP"));
    assertTrue(new ReflectionEquals(tokenizer.scanIdentifier()).matches(new Token(DefaultKeyword.GROUP, "GROUP", sql.indexOf("BY") - 1)));
    tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("`"));
    assertTrue(new ReflectionEquals(tokenizer.scanIdentifier()).matches(new Token(Literals.IDENTIFIER, "`table`", sql.indexOf("WHERE") - 1)));
    tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("YY"));
    assertTrue(new ReflectionEquals(tokenizer.scanIdentifier()).matches(new Token(Literals.IDENTIFIER, "YY", sql.indexOf("="))));
    tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("=-"));
    assertTrue(new ReflectionEquals(tokenizer.scanSymbol()).matches(new Token(Symbol.EQ, "=", sql.indexOf("=-") + 1)));
    tokenizer = new Tokenizer(sql, dictionary, sql.indexOf("'"));
    assertTrue(new ReflectionEquals(tokenizer.scanChars()).matches(new Token(Literals.CHARS, "xx", sql.indexOf("And") - 1)));
}
 
源代码2 项目: jtwig-core   文件: BlockContextTest.java
@Test
public void pollFirstMultiple() {
    map.put(IDENTIFIER, blockDefinitionsWithBothNodes);

    assertThat(map.get(IDENTIFIER).size(), is(2));

    Optional<BlockDefinition> definition1 = underTest.pollFirst(IDENTIFIER);
    assertThat(definition1.isPresent(), is(true));
    assertThat(definition1.get(), new ReflectionEquals(blockDefinition1));

    assertThat(map.get(IDENTIFIER).size(), is(1));

    Optional<BlockDefinition> definition2 = underTest.pollFirst(IDENTIFIER);
    assertThat(definition2.isPresent(), is(true));
    assertThat(definition2.get(), new ReflectionEquals(blockDefinition2));

    assertThat(map.get(IDENTIFIER).size(), is(0));
}
 
private void assertOrderBy(final SelectStatement actual) {
    Iterator<OrderItem> orderByColumns = getExpectedOrderByColumns().iterator();
    for (OrderItem each : actual.getOrderByItems()) {
        OrderItem expectedOrderItem = orderByColumns.next();
        assertTrue(new ReflectionEquals(expectedOrderItem).matches(each));
    }
    assertFalse(orderByColumns.hasNext());
}
 
private void assertGroupBy(final SelectStatement actual) {
    Iterator<OrderItem> groupByColumns = getExpectedGroupByColumns().iterator();
    for (OrderItem each : actual.getGroupByItems()) {
        OrderItem groupByColumn = groupByColumns.next();
        assertTrue(new ReflectionEquals(groupByColumn).matches(each));
    }
    assertFalse(groupByColumns.hasNext());
}
 
private void assertAggregationSelectItem(final SelectStatement actual) {
    Iterator<AggregationSelectItem> aggregationSelectItems = getExpectedAggregationSelectItems().iterator();
    for (AggregationSelectItem each : actual.getAggregationSelectItems()) {
        AggregationSelectItem expected = aggregationSelectItems.next();
        assertTrue(new ReflectionEquals(expected, "derivedAggregationSelectItems").matches(each));
        for (int i = 0; i < each.getDerivedAggregationSelectItems().size(); i++) {
            assertTrue(new ReflectionEquals(expected.getDerivedAggregationSelectItems().get(i)).matches(each.getDerivedAggregationSelectItems().get(i)));
        }
    }
    assertFalse(aggregationSelectItems.hasNext());
}
 
private void assertLimit(final SelectStatement actual, final boolean isPreparedStatement) {
    if (null != actual.getLimit()) {
        if (null != actual.getLimit().getOffset()) {
            assertTrue(new ReflectionEquals(buildExpectedLimit(isPreparedStatement).getOffset()).matches(actual.getLimit().getOffset()));
        }
        if (null != actual.getLimit().getRowCount()) {
            assertTrue(new ReflectionEquals(buildExpectedLimit(isPreparedStatement).getRowCount()).matches(actual.getLimit().getRowCount()));
        }
    }
}
 
源代码7 项目: jtwig-core   文件: BlockContextTest.java
@Test
public void addLastMultiple() throws Exception {
    underTest.addLast(blockNode1, resourceReference1);
    underTest.addLast(blockNode2, resourceReference2);

    assertThat(map.get(IDENTIFIER).get(0), new ReflectionEquals(blockDefinition1));
    assertThat(map.get(IDENTIFIER).get(1), new ReflectionEquals(blockDefinition2));
}
 
源代码8 项目: jtwig-core   文件: BlockContextTest.java
@Test
public void addFirstMultiple() throws Exception {
    underTest.addFirst(blockNode1, resourceReference1);
    underTest.addFirst(blockNode2, resourceReference2);

    assertThat(map.get(IDENTIFIER).get(1), new ReflectionEquals(blockDefinition1));
    assertThat(map.get(IDENTIFIER).get(0), new ReflectionEquals(blockDefinition2));
}
 
源代码9 项目: jtwig-core   文件: BlockContextTest.java
@Test
public void get() {
    map.put(IDENTIFIER, blockDefinitionsWithNode);

    Optional<BlockDefinition> definitionA = underTest.get(IDENTIFIER);
    assertThat(definitionA.isPresent(), is(true));
    assertThat(definitionA.get(), new ReflectionEquals(blockDefinition1));

    Optional<BlockDefinition> definitionB = underTest.get(IDENTIFIER, 0);
    assertThat(definitionB.isPresent(), is(true));
    assertThat(definitionB.get(), new ReflectionEquals(blockDefinition1));
}
 
源代码10 项目: jtwig-core   文件: BlockContextTest.java
@Test
public void getMultiple() {
    map.put(IDENTIFIER, blockDefinitionsWithBothNodes);

    Optional<BlockDefinition> definition1 = underTest.get(IDENTIFIER, 0);
    assertThat(definition1.isPresent(), is(true));
    assertThat(definition1.get(), new ReflectionEquals(blockDefinition1));

    Optional<BlockDefinition> definition2 = underTest.get(IDENTIFIER, 1);
    assertThat(definition2.isPresent(), is(true));
    assertThat(definition2.get(), new ReflectionEquals(blockDefinition2));
}
 
private void assertExpectedTables(final SQLStatement actual) {
    assertTrue(new ReflectionEquals(getExpectedTables()).matches(actual.getTables()));
}
 
private void assertExpectedConditions(final SQLStatement actual, final boolean isPreparedStatement) {
    assertTrue(new ReflectionEquals(buildExpectedConditions(isPreparedStatement)).matches(actual.getConditions()));
}
 
源代码13 项目: sharding-jdbc-1.5.1   文件: TokenizerTest.java
private void assertScanVariable(final String sql, final String literals) {
    String formatSql = String.format(sql, literals);
    Tokenizer tokenizer = new Tokenizer(formatSql, dictionary, formatSql.indexOf("@"));
    assertTrue(new ReflectionEquals(tokenizer.scanVariable()).matches(new Token(Literals.VARIABLE, literals, formatSql.indexOf("WHERE") - 1)));
}
 
源代码14 项目: sharding-jdbc-1.5.1   文件: TokenizerTest.java
private void assertScanNumber(final String sql, final String literals, final TokenType type) {
    String formatSql = String.format(sql, literals);
    Tokenizer tokenizer = new Tokenizer(formatSql, dictionary, sql.indexOf("=") + 1);
    assertTrue(new ReflectionEquals(tokenizer.scanNumber()).matches(new Token(type, literals, formatSql.length())));
}
 
源代码15 项目: sharding-jdbc-1.5.1   文件: TokenizerTest.java
private void assertScanHexDecimal(final String sql, final String literals, final TokenType type) {
    String formatSql = String.format(sql, literals);
    Tokenizer tokenizer = new Tokenizer(formatSql, dictionary, sql.indexOf("=") + 1);
    assertTrue(new ReflectionEquals(tokenizer.scanHexDecimal()).matches(new Token(type, literals, formatSql.length())));
}
 
源代码16 项目: jtwig-core   文件: BlockContextTest.java
@Test
public void addLast() throws Exception {
    underTest.addLast(blockNode1, resourceReference1);

    assertThat(map.get(IDENTIFIER).peek(), new ReflectionEquals(blockDefinition1));
}
 
源代码17 项目: jtwig-core   文件: BlockContextTest.java
@Test
public void addLastFirst() throws Exception {
    underTest.addFirst(blockNode1, resourceReference1);

    assertThat(map.get(IDENTIFIER).peek(), new ReflectionEquals(blockDefinition1));
}
 
源代码18 项目: tinkerpop   文件: MockitoHamcrestMatcherAdapter.java
public static MockitoHamcrestMatcherAdapter reflectionEquals(final Object wanted, final String... excludeFields) {
    return new MockitoHamcrestMatcherAdapter(new ReflectionEquals(wanted, excludeFields));
}
 
源代码19 项目: astor   文件: Matchers.java
/**
 * Object argument that is reflection-equal to the given value with support for excluding
 * selected fields from a class.
 * <p>
 * This matcher can be used when equals() is not implemented on compared objects.
 * Matcher uses java reflection API to compare fields of wanted and actual object.
 * <p>
 * Works similarly to EqualsBuilder.reflectionEquals(this, other, exlucdeFields) from
 * apache commons library.
 * <p>
 * <b>Warning</b> The equality check is shallow!
 * <p>
 * See examples in javadoc for {@link Matchers} class
 * 
 * @param value
 *            the given value.
 * @param excludeFields
 *            fields to exclude, if field does not exist it is ignored.
 * @return <code>null</code>.
 */
public static <T> T refEq(T value, String... excludeFields) {
    return reportMatcher(new ReflectionEquals(value, excludeFields)).<T>returnNull();
}
 
源代码20 项目: astor   文件: Matchers.java
/**
 * Object argument that is reflection-equal to the given value with support for excluding
 * selected fields from a class.
 * <p>
 * This matcher can be used when equals() is not implemented on compared objects.
 * Matcher uses java reflection API to compare fields of wanted and actual object.
 * <p>
 * Works similarly to EqualsBuilder.reflectionEquals(this, other, exlucdeFields) from
 * apache commons library.
 * <p>
 * <b>Warning</b> The equality check is shallow!
 * <p>
 * See examples in javadoc for {@link Matchers} class
 * 
 * @param value
 *            the given value.
 * @param excludeFields
 *            fields to exclude, if field does not exist it is ignored.
 * @return <code>null</code>.
 */
public static <T> T refEq(T value, String... excludeFields) {
    return reportMatcher(new ReflectionEquals(value, excludeFields)).<T>returnNull();
}
 
 类所在包
 同包方法