org.assertj.core.internal.Objects.assertEqual()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(221)

本文整理了Java中org.assertj.core.internal.Objects.assertEqual()方法的一些代码示例,展示了Objects.assertEqual()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Objects.assertEqual()方法的具体详情如下:
包路径:org.assertj.core.internal.Objects
类名称:Objects
方法名:assertEqual

Objects.assertEqual介绍

[英]Asserts that two objects are equal.
[中]断言两个对象相等。

代码示例

代码示例来源:origin: org.assertj/assertj-core

  1. /** {@inheritDoc} */
  2. @Override
  3. public SELF isEqualTo(Object expected) {
  4. objects.assertEqual(info, actual, expected);
  5. return myself;
  6. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. /** {@inheritDoc} */
  2. @Override
  3. public SELF isEqualTo(Object expected) {
  4. objects.assertEqual(info, actual, expected);
  5. return myself;
  6. }

代码示例来源:origin: org.assertj/assertj-core

  1. /**
  2. * Verifies that the actual group contains only the given values and nothing else, <b>in order</b>.
  3. * <p>
  4. * Example :
  5. * <pre><code class='java'> // assertion will pass
  6. * assertThat(new byte[] { 1, 2, 3 }).containsExactly((byte) 1, (byte) 2, (byte) 3);
  7. *
  8. * // assertion will fail as actual and expected order differ
  9. * assertThat(new byte[] { 1, 2, 3 }).containsExactly((byte) 2, (byte) 1, (byte) 3);</code></pre>
  10. *
  11. * @param values the given values.
  12. * @return {@code this} assertion object.
  13. * @throws NullPointerException if the given argument is {@code null}.
  14. * @throws AssertionError if the actual group is {@code null}.
  15. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual
  16. * group
  17. * contains some or none of the given values, or the actual group contains more values
  18. * than the given ones
  19. * or values are the same but the order is not.
  20. */
  21. public SELF containsExactly(byte... values) {
  22. objects.assertEqual(info, actual, values);
  23. return myself;
  24. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. /**
  2. * Verifies that the actual group contains only the given values and nothing else, <b>in order</b>.
  3. * <p>
  4. * Example :
  5. * <pre><code class='java'> // assertion will pass
  6. * assertThat(new byte[] { 1, 2, 3 }).containsExactly((byte) 1, (byte) 2, (byte) 3);
  7. *
  8. * // assertion will fail as actual and expected order differ
  9. * assertThat(new byte[] { 1, 2, 3 }).containsExactly((byte) 2, (byte) 1, (byte) 3);</code></pre>
  10. *
  11. * @param values the given values.
  12. * @return {@code this} assertion object.
  13. * @throws NullPointerException if the given argument is {@code null}.
  14. * @throws AssertionError if the actual group is {@code null}.
  15. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual
  16. * group
  17. * contains some or none of the given values, or the actual group contains more values
  18. * than the given ones
  19. * or values are the same but the order is not.
  20. */
  21. public SELF containsExactly(byte... values) {
  22. objects.assertEqual(info, actual, values);
  23. return myself;
  24. }

代码示例来源:origin: org.assertj/assertj-core

  1. /**
  2. * Verifies that the object under test returns the given expected value from the given {@link Function},
  3. * a typical usage is to pass a method reference to assert object's property.
  4. * <p>
  5. * Wrapping the given {@link Function} with {@link Assertions#from(Function)} makes the assertion more readable.
  6. * <p>
  7. * Example:
  8. * <pre><code class="java"> // from is not mandatory but it makes the assertions more readable
  9. * assertThat(frodo).returns("Frodo", from(TolkienCharacter::getName))
  10. * .returns("Frodo", TolkienCharacter::getName) // no from :(
  11. * .returns(HOBBIT, from(TolkienCharacter::getRace));</code></pre>
  12. *
  13. * @param expected the value the object under test method's call should return.
  14. * @param from {@link Function} used to acquire the value to test from the object under test. Must not be {@code null}
  15. * @param <T> the expected value type the given {@code method} returns.
  16. * @return {@code this} assertion object.
  17. * @throws NullPointerException if given {@code from} function is null
  18. */
  19. public <T> SELF returns(T expected, Function<ACTUAL, T> from) {
  20. requireNonNull(from, "The given getter method/Function must not be null");
  21. objects.assertEqual(info, from.apply(actual), expected);
  22. return myself;
  23. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. /**
  2. * Verifies that the object under test returns the given expected value from the given {@link Function},
  3. * a typical usage is to pass a method reference to assert object's property.
  4. * <p>
  5. * Wrapping the given {@link Function} with {@link Assertions#from(Function)} makes the assertion more readable.
  6. * <p>
  7. * Example:
  8. * <pre><code class="java"> // from is not mandatory but it makes the assertions more readable
  9. * assertThat(frodo).returns("Frodo", from(TolkienCharacter::getName))
  10. * .returns("Frodo", TolkienCharacter::getName) // no from :(
  11. * .returns(HOBBIT, from(TolkienCharacter::getRace));</code></pre>
  12. *
  13. * @param expected the value the object under test method's call should return.
  14. * @param from {@link Function} used to acquire the value to test from the object under test. Must not be {@code null}
  15. * @param <T> the expected value type the given {@code method} returns.
  16. * @return {@code this} assertion object.
  17. * @throws NullPointerException if given {@code from} function is null
  18. */
  19. public <T> SELF returns(T expected, Function<ACTUAL, T> from) {
  20. requireNonNull(from, "The given getter method/Function must not be null");
  21. objects.assertEqual(info, from.apply(actual), expected);
  22. return myself;
  23. }

代码示例来源:origin: org.assertj/assertj-core

  1. @Override
  2. public IterableAssert<ELEMENT> isEqualTo(Object expected) {
  3. if (actual instanceof LazyIterable) {
  4. objects.assertEqual(info, asLazyIterable().iterator, expected);
  5. return myself;
  6. }
  7. return super.isEqualTo(expected);
  8. }

代码示例来源:origin: palantir/atlasdb

  1. private void checkPresentAndCheckCount(MetricName metricName, long count) {
  2. assertMetricExists(metricName);
  3. objects.assertEqual(writableAssertionInfo, taggedMetricRegistry.meter(metricName).getCount(), count);
  4. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasEntriesReadConservativeEqualTo(long value) {
  2. objects.assertEqual(info, getGaugeConservative(AtlasDbMetricNames.ENTRIES_READ).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasTombstonesPutConservativeEqualTo(long value) {
  2. objects.assertEqual(info, getGaugeConservative(AtlasDbMetricNames.TOMBSTONES_PUT).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasSweepTimestampConservativeEqualTo(Long value) {
  2. objects.assertEqual(info, getGaugeConservative(AtlasDbMetricNames.SWEEP_TS).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasTombstonesPutThoroughEqualTo(long value) {
  2. objects.assertEqual(info, getGaugeThorough(AtlasDbMetricNames.TOMBSTONES_PUT).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasLegacyOutcomeEqualTo(SweepOutcome outcome, long value) {
  2. objects.assertEqual(info, getGaugeForLegacyOutcome(outcome).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasLastSweptTimestampConservativeEqualTo(Long value) {
  2. objects.assertEqual(info, getGaugeConservative(AtlasDbMetricNames.LAST_SWEPT_TS).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasMillisSinceLastSweptConservativeEqualTo(Long value) {
  2. objects.assertEqual(info, getGaugeConservative(AtlasDbMetricNames.LAG_MILLIS).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasEntriesReadThoroughEqualTo(long value) {
  2. objects.assertEqual(info, getGaugeThorough(AtlasDbMetricNames.ENTRIES_READ).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasAbortedWritesDeletedThoroughEqualTo(long value) {
  2. objects.assertEqual(info, getGaugeThorough(AtlasDbMetricNames.ABORTED_WRITES_DELETED).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasMillisSinceLastSweptThoroughEqualTo(long value) {
  2. objects.assertEqual(info, getGaugeThorough(AtlasDbMetricNames.LAG_MILLIS).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasAbortedWritesDeletedConservativeEquals(long value) {
  2. objects.assertEqual(info, getGaugeConservative(AtlasDbMetricNames.ABORTED_WRITES_DELETED).getValue(), value);
  3. }

代码示例来源:origin: palantir/atlasdb

  1. public void hasTargetedOutcomeEqualTo(SweepOutcome outcome, Long value) {
  2. objects.assertEqual(info, getGaugeForTargetedOutcome(outcome).getValue(), value);
  3. }

相关文章