proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldHavePackage.java | ShouldHavePackage | shouldHavePackage | class ShouldHavePackage extends BasicErrorMessageFactory {
private static final String SHOULD_HAVE_PACKAGE = new StringJoiner("%n", "%n", "").add("Expecting")
.add(" %s")
... |
final Package actualPackage = actual.getPackage();
return (actualPackage == null)
? new ShouldHavePackage(actual, packageName)
: new ShouldHavePackage(actual, packageName, actualPackage.getName());
| 493 | 55 | 548 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldHaveParent.java | ShouldHaveParent | shouldHaveParent | class ShouldHaveParent extends BasicErrorMessageFactory {
@VisibleForTesting
public static final String PATH_NO_PARENT = "%nExpecting path%n %s%nto have parent:%n %s%nbut did not have one.";
@VisibleForTesting
public static final String PATH_NOT_EXPECTED_PARENT = "%nExpecting path%n %s%nto have parent:%n ... |
final Path actualParent = actual.getParent();
return actualParent == null
? new ShouldHaveParent(actual, expected)
: new ShouldHaveParent(actual, actualParent, expected);
| 524 | 49 | 573 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldHavePeriod.java | ShouldHavePeriod | shouldHaveDays | class ShouldHavePeriod extends BasicErrorMessageFactory {
private static final String EXPECTED_PREFIX = "%n" +
"Expecting Period:%n" +
" %s%n" +
"to have %s ";
private S... |
final String metric = Math.abs(expectedDays) == 1 ? "day" : "days";
return new ShouldHavePeriod(actual, actualDays, expectedDays, metric);
| 300 | 47 | 347 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldHaveRootCause.java | ShouldHaveRootCause | shouldHaveRootCause | class ShouldHaveRootCause extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldHaveRootCauseWithMessage(Throwable actual, Throwable actualCause,
String expectedMessage) {
checkArgument(actual != null, "actual should not be n... |
checkArgument(actual != null, "actual should not be null");
checkArgument(expectedCause != null, "expected cause should not be null");
// actualCause has no cause
if (actualCause == null) return new ShouldHaveRootCause(actual, expectedCause);
// same message => different type
if (Objects.equals... | 1,006 | 196 | 1,202 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldHaveRootCauseExactlyInstance.java | ShouldHaveRootCauseExactlyInstance | shouldHaveRootCauseExactlyInstance | class ShouldHaveRootCauseExactlyInstance extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link org.assertj.core.error.BasicErrorMessageFactory}</code>.
*
* @param actual the actual value in the failed assertion.
* @param expectedCauseType the expected cause instance.
* @return the creat... |
return Throwables.getRootCause(actual) == null
? new ShouldHaveRootCauseExactlyInstance(expectedCauseType, actual)
: new ShouldHaveRootCauseExactlyInstance(actual, expectedCauseType);
| 378 | 61 | 439 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldHaveRootCauseInstance.java | ShouldHaveRootCauseInstance | shouldHaveRootCauseInstance | class ShouldHaveRootCauseInstance extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link BasicErrorMessageFactory}</code>.
*
* @param actual the actual value in the failed assertion.
* @param expectedCauseType the expected cause type.
* @return the created {@code ErrorMessageFactory}.
... |
return Throwables.getRootCause(actual) == null
? new ShouldHaveRootCauseInstance(expectedCauseType, actual)
: new ShouldHaveRootCauseInstance(actual, expectedCauseType);
| 355 | 55 | 410 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldHaveSameDimensionsAs.java | ShouldHaveSameDimensionsAs | shouldHaveSameDimensionsAs | class ShouldHaveSameDimensionsAs extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldHaveSameDimensionsAs}</code>.
* @param actual the actual value in the failed assertion.
* @param expected the expected value in the failed assertion.
* @param actualSize the size of {@code actual}.
... |
return new ShouldHaveSameDimensionsAs(rowIndex, actualRowSize, expectedRowSize, actualRow, expectedRow, actual, expected);
| 683 | 35 | 718 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldHaveSuperclass.java | ShouldHaveSuperclass | shouldHaveSuperclass | class ShouldHaveSuperclass extends BasicErrorMessageFactory {
private static final String SHOULD_HAVE_SUPERCLASS = new StringJoiner("%n", "%n", "").add("Expecting")
.add(" %s")
... |
Class<?> actualSuperclass = actual.getSuperclass();
return (actualSuperclass == null)
? new ShouldHaveSuperclass(actual, superclass)
: new ShouldHaveSuperclass(actual, superclass, actualSuperclass);
| 414 | 61 | 475 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldMatch.java | ShouldMatch | shouldMatch | class ShouldMatch extends BasicErrorMessageFactory {
// @format:off
public static final String ADVICE = format("%n%n"+
"You can use 'matches(Predicate p, String description)' to have a better error message%n" +
"For example:%n" +
... |
requireNonNull(predicateDescription, "The predicate description must not be null");
return new ShouldMatch(actual, predicateDescription);
| 398 | 34 | 432 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotAccept.java | ShouldNotAccept | shouldNotAccept | class ShouldNotAccept extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldNotAccept}</code>.
*
* @param <T> guarantees that the type of the value value and the generic type of the {@code Predicate} are the same.
* @param predicate the {@code Predicate}.
* @param value the value v... |
requireNonNull(description, "The predicate description must not be null");
return new ShouldNotAccept(value, description);
| 228 | 32 | 260 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotBeEmpty.java | ShouldNotBeEmpty | shouldNotBeEmpty | class ShouldNotBeEmpty extends BasicErrorMessageFactory {
private static final ShouldNotBeEmpty INSTANCE = new ShouldNotBeEmpty("%nExpecting actual not to be empty");
/**
* Returns the singleton instance of this class.
* @return the singleton instance of this class.
*/
public static ErrorMessageFactory... |
return new ShouldNotBeEmpty("%nExpecting path %s not to be empty", actual);
| 311 | 26 | 337 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotBeEqualComparingFieldByFieldRecursively.java | ShouldNotBeEqualComparingFieldByFieldRecursively | shouldNotBeEqualComparingFieldByFieldRecursively | class ShouldNotBeEqualComparingFieldByFieldRecursively extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldNotBeEqualComparingFieldByFieldRecursively(Object actual, Object other,
RecursiveComparisonConfigurati... |
if (actual == null)
return new ShouldNotBeEqualComparingFieldByFieldRecursively("%n" +
"Expecting actual not to be equal to other but both are null.");
return new ShouldNotBeEqualComparingFieldByFieldRecursively("%n" +
... | 321 | 111 | 432 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotBeEqualWithinPercentage.java | ShouldNotBeEqualWithinPercentage | shouldNotBeEqualWithinPercentage | class ShouldNotBeEqualWithinPercentage extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldNotBeEqualWithinPercentage}</code>.
*
* @param <T> the type of the actual value and the type of values that given {@code Condition} takes.
* @param actual the actual value in the failed assert... |
double expectedPercentage = difference.doubleValue() / expected.doubleValue() * 100d;
return new ShouldNotBeEqualWithinPercentage(actual, expected, percentage, expectedPercentage);
| 335 | 54 | 389 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotBeExactlyInstanceOf.java | ShouldNotBeExactlyInstanceOf | shouldNotBeExactlyInstance | class ShouldNotBeExactlyInstanceOf extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldNotBeExactlyInstanceOf}</code>.
* @param actual the actual value in the failed assertion.
* @param type the type {@code actual} is expected to be.
* @return the created {@code ErrorMessageFactory}... |
return actual instanceof Throwable ? new ShouldNotBeExactlyInstanceOf((Throwable) actual, type)
: new ShouldNotBeExactlyInstanceOf(actual, type);
| 256 | 46 | 302 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotBeInstance.java | ShouldNotBeInstance | shouldNotBeInstance | class ShouldNotBeInstance extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldNotBeInstance}</code>.
* @param actual the actual value in the failed assertion.
* @param type the type {@code actual} is expected to belong to.
* @return the created {@code ErrorMessageFactory}.
*/
p... |
return actual instanceof Throwable ? new ShouldNotBeInstance((Throwable) actual, type)
: new ShouldNotBeInstance(actual, type);
| 236 | 38 | 274 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotBeInstanceOfAny.java | ShouldNotBeInstanceOfAny | shouldNotBeInstanceOfAny | class ShouldNotBeInstanceOfAny extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldNotBeInstanceOfAny}</code>.
* @param actual the actual value in the failed assertion.
* @param types contains the type or types {@code actual} is expected to belong to.
* @return the created {@code Er... |
return actual instanceof Throwable ? new ShouldNotBeInstanceOfAny((Throwable) actual, types)
: new ShouldNotBeInstanceOfAny(actual, types);
| 266 | 42 | 308 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotBeNull.java | ShouldNotBeNull | shouldNotBeNull | class ShouldNotBeNull extends BasicErrorMessageFactory {
private static final ShouldNotBeNull INSTANCE = new ShouldNotBeNull("%nExpecting actual not to be null");
/**
* Returns the default instance of this class.
* @return the default instance of this class.
*/
public static ErrorMessageFactory shouldN... |
return new ShouldNotBeNull(format("%nExpecting %s not to be null", label));
| 186 | 27 | 213 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotContainCharSequence.java | ShouldNotContainCharSequence | shouldNotContainIgnoringCase | class ShouldNotContainCharSequence extends BasicErrorMessageFactory {
private ShouldNotContainCharSequence(String format, CharSequence actual, CharSequence sequence,
ComparisonStrategy comparisonStrategy) {
super(format, actual, sequence, comparisonStrategy);
}
private... |
return new ShouldNotContainCharSequence("%n" +
"Expecting actual:%n" +
" %s%n" +
"not to contain (ignoring case):%n" +
" %s%n" +
... | 857 | 106 | 963 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotContainKeys.java | ShouldNotContainKeys | shouldNotContainKeys | class ShouldNotContainKeys extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldNotContainKeys}</code>.
*
* @param <K> key type
* @param actual the actual value in the failed assertion.
* @param keys the unexpected keys
* @return the created {@code ErrorMessageFactory}.
*/
... |
if (keys.size() == 1) return shouldNotContainKey(actual, keys.iterator().next());
return new ShouldNotContainKeys(actual, keys);
| 191 | 43 | 234 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotMatch.java | ShouldNotMatch | shouldNotMatch | class ShouldNotMatch extends BasicErrorMessageFactory {
// @format:off
public static final String ADVICE = format("%n%n"+
"You can use 'doesNotMatch(Predicate p, String description)' to have a better error message%n" +
"For example... |
requireNonNull(predicateDescription, "The predicate description must not be null");
return new ShouldNotMatch(actual, predicateDescription);
| 407 | 35 | 442 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldNotSatisfyPredicateRecursively.java | ShouldNotSatisfyPredicateRecursively | shouldNotSatisfyRecursively | class ShouldNotSatisfyPredicateRecursively extends BasicErrorMessageFactory {
private static final String INDENT = " ";
private static final String NEW_LINE = format("%n");
public static ErrorMessageFactory shouldNotSatisfyRecursively(RecursiveAssertionConfiguration recursiveAssertionConfiguration,
... |
List<String> fieldsDescription = failedFields.stream().map(FieldLocation::getPathToUseInErrorReport).collect(toList());
StringBuilder builder = new StringBuilder(NEW_LINE);
builder.append("The following fields did not satisfy the predicate:").append(NEW_LINE);
builder.append(INDENT + fieldsDescription.... | 130 | 145 | 275 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldOnlyHaveElementsOfTypes.java | ShouldOnlyHaveElementsOfTypes | resolveClassNames | class ShouldOnlyHaveElementsOfTypes extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldOnlyHaveElementsOfTypes}</code>.
*
* @param actual the object value in the failed assertion.
* @param types the expected classes and interfaces.
* @param mismatches elements that are not an i... |
StringBuilder builder = new StringBuilder();
for (Object element : elements) {
if (builder.length() > 0) {
builder.append(", ");
}
String formatted = CONFIGURATION_PROVIDER.representation().toStringOf(element);
builder.append(formatted);
if (element != null && !formatte... | 330 | 138 | 468 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldOnlyHaveFields.java | ShouldOnlyHaveFields | create | class ShouldOnlyHaveFields extends BasicErrorMessageFactory {
/**
* Creates a new <code>{@link ShouldOnlyHaveFields}</code>.
*
* @param actual the actual value in the failed assertion.
* @param expected expected fields for this class
* @param notFound fields in {@code expected} not found in the {@code... |
if (isNullOrEmpty(notExpected)) {
return new ShouldOnlyHaveFields(actual, expected, notFound, NOT_FOUND_ONLY, declared);
}
if (isNullOrEmpty(notFound)) {
return new ShouldOnlyHaveFields(actual, expected, notExpected, NOT_EXPECTED_ONLY, declared);
}
return new ShouldOnlyHaveFields(actu... | 795 | 111 | 906 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ShouldSatisfyOnlyOnce.java | ShouldSatisfyOnlyOnce | shouldSatisfyOnlyOnce | class ShouldSatisfyOnlyOnce extends BasicErrorMessageFactory {
private static final String NO_ELEMENT_SATISFIED_REQUIREMENTS = "%nExpecting exactly one element of actual:%n" +
" %s%n" +
... |
return satisfiedElements.isEmpty() ? new ShouldSatisfyOnlyOnce(actual) : new ShouldSatisfyOnlyOnce(actual, satisfiedElements);
| 430 | 36 | 466 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/SubarraysShouldHaveSameSize.java | SubarraysShouldHaveSameSize | subarraysShouldHaveSameSize | class SubarraysShouldHaveSameSize extends BasicErrorMessageFactory {
private static final String MESSAGE = "%n" +
"actual and expected 2d arrays should be deeply equal but rows at index %s differ:%n" +
"actual[%s] size is %s and expected... |
return new SubarraysShouldHaveSameSize(actual, expected, actualSubArray, actualSubArrayLength, expectedSubArray,
expectedSubArrayLength, index);
| 568 | 42 | 610 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/UnsatisfiedRequirement.java | UnsatisfiedRequirement | describe | class UnsatisfiedRequirement {
private final Object elementNotSatisfyingRequirements;
private final String errorMessage;
public UnsatisfiedRequirement(Object elementNotSatisfyingRequirements, String errorMessage) {
this.elementNotSatisfyingRequirements = elementNotSatisfyingRequirements;
this.errorMessa... |
return format("%s%n" +
"- element index: %s%n" +
"- error: %s",
info.representation().toStringOf(elementNotSatisfyingRequirements), index, errorMessage);
| 201 | 56 | 257 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/ZippedElementsShouldSatisfy.java | ZippedElementsShouldSatisfy | describe | class ZippedElementsShouldSatisfy extends BasicErrorMessageFactory {
private static final String DELIMITER = String.format("%n%n- ");
public static ErrorMessageFactory zippedElementsShouldSatisfy(AssertionInfo info,
Iterable<?> actual, Iterable<?> ot... |
List<String> errorsToStrings = zipSatisfyErrors.stream()
.map(error -> ZipSatisfyError.describe(info, error))
.collect(toList());
return escapePercent(DELIMITER + String.join(DELIMITER, errorsToStrings));
| 562 | 80 | 642 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/future/ShouldBeCompletedWithin.java | ShouldBeCompletedWithin | toChronoUnit | class ShouldBeCompletedWithin extends BasicErrorMessageFactory {
private static final String SHOULD_BE_COMPLETED_WITHIN_DURATION = "%n"
+ "Expecting%n"
+ " <%s>%n"
... |
switch (timeUnit) {
case NANOSECONDS:
return ChronoUnit.NANOS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
case SECONDS:
return ChronoUnit.SECONDS;
case MINUTES:
return ChronoUnit.MINUTES;
case HOURS:
return C... | 524 | 160 | 684 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/uri/ShouldHaveAnchor.java | ShouldHaveAnchor | shouldHaveAnchor | class ShouldHaveAnchor extends BasicErrorMessageFactory {
private static final String SHOULD_HAVE_ANCHOR = "%nExpecting anchor of%n <%s>%nto be:%n <%s>%nbut was:%n <%s>";
private static final String SHOULD_NOT_HAVE_ANCHOR = "%nExpecting actual:%n <%s>%nnot to have an anchor but had:%n <%s>";
public static ... |
return expectedAnchor == null ? new ShouldHaveAnchor(actual) : new ShouldHaveAnchor(actual, expectedAnchor);
| 243 | 33 | 276 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/uri/ShouldHaveFragment.java | ShouldHaveFragment | shouldHaveFragment | class ShouldHaveFragment extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldHaveFragment(URI actual, String expectedFragment) {<FILL_FUNCTION_BODY>}
private ShouldHaveFragment(URI actual, String expectedFragment) {
super("%nExpecting fragment of%n <%s>%nto be:%n <%s>%nbut was:%n <%s>... |
return expectedFragment == null ? new ShouldHaveFragment(actual) : new ShouldHaveFragment(actual, expectedFragment);
| 170 | 29 | 199 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/uri/ShouldHaveParameter.java | ShouldHaveParameter | shouldHaveNoParameters | class ShouldHaveParameter extends BasicErrorMessageFactory {
private static final String SHOULD_HAVE_PARAMETER_BUT_WAS_MISSING = "%nExpecting actual:%n <%s>%nto have parameter:%n <%s>%nbut was missing";
private static final String SHOULD_HAVE_PARAMETER_WITHOUT_VALUE_BUT_PARAMETER_WAS_MISSING = "%nExpecting actua... |
String parametersDescription = parameterNames.size() == 1 ? parameterNames.iterator().next()
: parameterNames.toString();
return new ShouldHaveParameter(SHOULD_HAVE_NO_PARAMETERS, actual, parametersDescription);
| 1,947 | 59 | 2,006 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/uri/ShouldHavePath.java | ShouldHavePath | shouldHavePath | class ShouldHavePath extends BasicErrorMessageFactory {
private static final String SHOULD_NOT_HAVE_PATH = "%nExpecting actual:%n <%s>%nnot to have a path but had:%n <%s>";
private static final String SHOULD_HAVE_PATH = "%nExpecting path of%n <%s>%nto be:%n <%s>%nbut was:%n <%s>";
public static ErrorMessag... |
return isNullOrEmpty(expectedPath) ? new ShouldHavePath(actual) : new ShouldHavePath(actual, expectedPath);
| 358 | 33 | 391 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/uri/ShouldHavePort.java | ShouldHavePort | shouldHavePort | class ShouldHavePort extends BasicErrorMessageFactory {
private static final int NO_PORT = -1;
private static final String SHOULD_HAVE_NO_PORT = "%nExpecting actual:%n <%s>%nnot to have a port but had:%n <%s>";
private static final String SHOULD_HAVE_PORT = "%nExpecting port of%n <%s>%nto be:%n <%s>%nbut was... |
return expectedPort == NO_PORT ? new ShouldHavePort(actual) : new ShouldHavePort(actual, expectedPort);
| 372 | 31 | 403 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/uri/ShouldHaveQuery.java | ShouldHaveQuery | shouldHaveQuery | class ShouldHaveQuery extends BasicErrorMessageFactory {
private static final String SHOULD_HAVE_QUERY = "%nExpecting query of%n <%s>%nto be:%n <%s>%nbut was:%n <%s>";
private static final String SHOULD_NOT_HAVE_QUERY = "%nExpecting actual:%n <%s>%nnot to have a query but had:%n <%s>";
public static ErrorM... |
return expectedQuery == null ? new ShouldHaveQuery(actual) : new ShouldHaveQuery(actual, expectedQuery);
| 363 | 29 | 392 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/error/uri/ShouldHaveUserInfo.java | ShouldHaveUserInfo | shouldHaveUserInfo | class ShouldHaveUserInfo extends BasicErrorMessageFactory {
private static final String SHOULD_HAVE_NO_USER_INFO = "%nExpecting actual:%n <%s>%nnot to have user info but had:%n <%s>";
private static final String SHOULD_HAVE_USER_INFO = "%nExpecting user info of%n <%s>%nto be:%n <%s>%nbut was:%n <%s>";
publ... |
return expectedUserInfo == null ? new ShouldHaveUserInfo(actual) : new ShouldHaveUserInfo(actual, expectedUserInfo);
| 391 | 33 | 424 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public java.lang.String create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation) ,public java.lang.String create(org.assertj.core.description.Description) ,public java.lang.String create() ,public boolean ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/extractor/ByNameMultipleExtractor.java | ByNameMultipleExtractor | apply | class ByNameMultipleExtractor implements Function<Object, Tuple> {
private final String[] fieldsOrProperties;
ByNameMultipleExtractor(String... fieldsOrProperties) {
this.fieldsOrProperties = fieldsOrProperties;
}
@Override
public Tuple apply(Object input) {<FILL_FUNCTION_BODY>}
private List<Functio... |
checkArgument(fieldsOrProperties != null, "The names of the fields/properties to read should not be null");
checkArgument(fieldsOrProperties.length > 0, "The names of the fields/properties to read should not be empty");
checkArgument(input != null, "The object to extract fields/properties from should not b... | 198 | 130 | 328 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/groups/FieldsOrPropertiesExtractor.java | FieldsOrPropertiesExtractor | checkObjectToExtractFromIsNotNull | class FieldsOrPropertiesExtractor {
/**
* Call {@link #extract(Iterable, Function)} after converting objects to an iterable.
* <p>
* Behavior is described in javadoc {@link AbstractObjectArrayAssert#extracting(Function)}
* @param <F> type of elements to extract a value from
* @param <T> the extracted ... |
if (object == null) throw new AssertionError("Expecting actual not to be null");
| 388 | 26 | 414 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/groups/Properties.java | Properties | checkIsNotNullOrEmpty | class Properties<T> {
@VisibleForTesting
final String propertyName;
final Class<T> propertyType;
@VisibleForTesting
PropertySupport propertySupport = PropertySupport.instance();
/**
* Creates a new <code>{@link Properties}</code>.
* @param <T> the type of value to extract.
* @param propertyName ... |
requireNonNull(propertyName, "The name of the property to read should not be null");
checkArgument(propertyName.length() > 0, "The name of the property to read should not be empty");
| 1,024 | 51 | 1,075 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/groups/Tuple.java | Tuple | equals | class Tuple {
private final List<Object> values;
public Tuple(Object... values) {
this.values = list(values);
}
public Object[] toArray() {
return values.toArray();
}
public List<Object> toList() {
return values;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
... |
if (this == obj) return true;
if (!(obj instanceof Tuple)) return false;
Tuple other = (Tuple) obj;
return Arrays.deepEquals(values.toArray(), other.values.toArray());
| 205 | 60 | 265 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/AbstractComparisonStrategy.java | AbstractComparisonStrategy | arrayContains | class AbstractComparisonStrategy implements ComparisonStrategy {
@Override
public Iterable<?> duplicatesFrom(Iterable<?> iterable) {
if (isNullOrEmpty(iterable)) return EMPTY_SET;
Set<Object> noDuplicates = newSetUsingComparisonStrategy();
Set<Object> duplicatesWithOrderPreserved = new LinkedHashSet<>... |
for (int i = 0; i < getLength(array); i++) {
Object element = Array.get(array, i);
if (areEqual(element, value)) return true;
}
return false;
| 423 | 58 | 481 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Arrays2D.java | Arrays2D | assertNumberOfRows | class Arrays2D {
private static final Arrays2D INSTANCE = new Arrays2D();
/**
* Returns the singleton instance of this class based on {@link StandardComparisonStrategy}.
*
* @return the singleton instance of this class based on {@link StandardComparisonStrategy}.
*/
public static Arrays2D instance()... |
assertNotNull(info, array);
int sizeOfActual = sizeOf(array);
if (sizeOfActual != expectedSize)
throw failures.failure(info, ShouldHaveDimensions.shouldHaveFirstDimension(array, sizeOfActual, expectedSize));
| 1,499 | 66 | 1,565 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/AtomicReferenceArrayElementComparisonStrategy.java | AtomicReferenceArrayElementComparisonStrategy | areEqual | class AtomicReferenceArrayElementComparisonStrategy<T> extends StandardComparisonStrategy {
private final Comparator<? super T> elementComparator;
public AtomicReferenceArrayElementComparisonStrategy(Comparator<? super T> elementComparator) {
this.elementComparator = elementComparator;
}
@SuppressWarning... |
if (actual == null && other == null) return true;
if (actual == null || other == null) return false;
// expecting actual and other to be T[]
return actual instanceof AtomicReferenceArray && isArray(other)
&& compareElementsOf((AtomicReferenceArray<T>) actual, (T[]) other);
| 356 | 82 | 438 | <methods>public boolean areEqual(java.lang.Object, java.lang.Object) ,public Iterable<?> duplicatesFrom(Iterable<?>) ,public static org.assertj.core.internal.StandardComparisonStrategy instance() ,public boolean isGreaterThan(java.lang.Object, java.lang.Object) ,public boolean isLessThan(java.lang.Object, java.lang.Obj... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/BigDecimals.java | BigDecimals | areEqual | class BigDecimals extends Numbers<BigDecimal> {
private static final BigDecimals INSTANCE = new BigDecimals();
/**
* Returns the singleton instance of this class based on {@link StandardComparisonStrategy}.
*
* @return the singleton instance of this class based on {@link StandardComparisonStrategy}.
... |
if (value1 == null) return value2 == null;
// we know value1 is not null
if (value2 == null) return false;
return value1.compareTo(value2) == 0;
| 404 | 55 | 459 | <methods>public void <init>() ,public void <init>(org.assertj.core.internal.ComparisonStrategy) ,public void assertIsBetween(org.assertj.core.api.AssertionInfo, java.math.BigDecimal, java.math.BigDecimal, java.math.BigDecimal) ,public void assertIsCloseTo(org.assertj.core.api.AssertionInfo, java.math.BigDecimal, java.m... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/BinaryDiff.java | BinaryDiff | diff | class BinaryDiff {
@VisibleForTesting
public BinaryDiffResult diff(File actual, byte[] expected) throws IOException {
return diff(actual.toPath(), expected);
}
@VisibleForTesting
public BinaryDiffResult diff(Path actual, byte[] expected) throws IOException {
try (InputStream actualStream = new Buffe... |
int index = 0;
while (true) {
int actual = actualStream.read();
int expected = expectedStream.read();
if (actual == -1 && expected == -1) return BinaryDiffResult.noDiff(); // reached end of both streams
if (actual != expected) return new BinaryDiffResult(index, expected, actual);
... | 216 | 97 | 313 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/BinaryDiffResult.java | BinaryDiffResult | describe | class BinaryDiffResult {
private static final int EOF = -1;
public final int offset;
public final String expected;
public final String actual;
/**
* Builds a new instance.
*
* @param offset the offset at which the difference occurred.
* @param expected the expected byte as an int in the range 0 ... |
return (b == EOF) ? "EOF" : "0x" + Integer.toHexString(b).toUpperCase();
| 267 | 37 | 304 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Booleans.java | Booleans | assertNotEqual | class Booleans {
private static final Booleans INSTANCE = new Booleans();
/**
* Returns the singleton instance of this class.
* @return the singleton instance of this class.
*/
public static Booleans instance() {
return INSTANCE;
}
@VisibleForTesting
Failures failures = Failures.instance();
... |
assertNotNull(info, actual);
if (actual != other) return;
throw failures.failure(info, shouldNotBeEqual(actual, other));
| 468 | 42 | 510 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Bytes.java | Bytes | absDiff | class Bytes extends Numbers<Byte> implements WholeNumbers<Byte> {
private static final Bytes INSTANCE = new Bytes();
/**
* Returns the singleton instance of this class.
*
* @return the singleton instance of this class.
*/
public static Bytes instance() {
return INSTANCE;
}
@VisibleForTestin... |
return (byte) Math.abs(actual - other); // TODO check corner case when diff > max byte
| 271 | 27 | 298 | <methods>public void <init>() ,public void <init>(org.assertj.core.internal.ComparisonStrategy) ,public void assertIsBetween(org.assertj.core.api.AssertionInfo, java.lang.Byte, java.lang.Byte, java.lang.Byte) ,public void assertIsCloseTo(org.assertj.core.api.AssertionInfo, java.lang.Byte, java.lang.Byte, Offset<java.la... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/CommonErrors.java | CommonErrors | wrongElementTypeForFlatExtracting | class CommonErrors {
public static NullPointerException arrayOfValuesToLookForIsNull() {
return new NullPointerException(ErrorMessages.arrayOfValuesToLookForIsNull());
}
public static NullPointerException iterableToLookForIsNull() {
return new NullPointerException(ErrorMessages.iterableToLookForIsNull()... |
throw new IllegalArgumentException("Flat extracting expects extracted values to be Iterables or arrays but was a "
+ group.getClass().getSimpleName());
| 248 | 39 | 287 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/CommonValidations.java | CommonValidations | checkLineCounts | class CommonValidations {
private static final Failures FAILURES = Failures.instance();
private CommonValidations() {}
static void checkIndexValueIsValid(Index index, int maximum) {
requireNonNull(index, "Index should not be null");
if (index.value <= maximum) return;
String errorMessage = "Index s... |
if (lineCountOfActual != lineCountOfOther)
throw FAILURES.failure(info, shouldHaveLinesCount(actual, lineCountOfActual, lineCountOfOther));
| 1,605 | 49 | 1,654 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/ComparatorBasedComparisonStrategy.java | ComparatorBasedComparisonStrategy | areEqual | class ComparatorBasedComparisonStrategy extends AbstractComparisonStrategy {
static final int NOT_EQUAL = -1;
// A raw type is necessary because we can't make assumptions on object to be compared.
@SuppressWarnings("rawtypes")
private final Comparator comparator;
// Comparator description used in assertion... |
// we don't check actual or expected for null, this should be done by the comparator, the rationale being that a
// comparator might consider null to be equals to some special value (like blank String and null)
return comparator.compare(actual, other) == 0;
| 1,934 | 70 | 2,004 | <methods>public non-sealed void <init>() ,public boolean arrayContains(java.lang.Object, java.lang.Object) ,public Iterable<?> duplicatesFrom(Iterable<?>) ,public boolean isGreaterThanOrEqualTo(java.lang.Object, java.lang.Object) ,public boolean isLessThan(java.lang.Object, java.lang.Object) ,public boolean isLessThanO... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Conditions.java | Conditions | assertIsNotNull | class Conditions {
private static final Conditions INSTANCE = new Conditions();
/**
* Returns the singleton instance of this class.
* @return the singleton instance of this class.
*/
public static Conditions instance() {
return INSTANCE;
}
@VisibleForTesting
Failures failures = Failures.inst... |
assertIsNotNull(condition, "The condition to evaluate should not be null");
| 1,203 | 21 | 1,224 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/ConfigurableRecursiveFieldByFieldComparator.java | ConfigurableRecursiveFieldByFieldComparator | toString | class ConfigurableRecursiveFieldByFieldComparator implements Comparator<Object> {
private RecursiveComparisonConfiguration configuration;
private RecursiveComparisonDifferenceCalculator recursiveComparisonDifferenceCalculator;
// for testing
ConfigurableRecursiveFieldByFieldComparator(RecursiveComparisonConfi... |
return format("recursive field/property by field/property comparator on all fields/properties using the following configuration:%n%s",
configuration);
| 498 | 39 | 537 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Diff.java | Diff | linesFromBufferedReader | class Diff {
@VisibleForTesting
public List<Delta<String>> diff(InputStream actual, InputStream expected) throws IOException {
return diff(readerFor(actual), readerFor(expected));
}
@VisibleForTesting
public List<Delta<String>> diff(InputStream actual, String expected) throws IOException {
return di... |
String line;
List<String> lines = new ArrayList<>();
while ((line = reader.readLine()) != null) {
lines.add(line);
}
return lines;
| 567 | 52 | 619 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Digests.java | Digests | digestDiff | class Digests {
private static final int BUFFER_SIZE = 1024 * 8;
private Digests() {}
public static String toHex(byte[] digest) {
requireNonNull(digest, "The digest should not be null");
StringBuilder hex = new StringBuilder(digest.length * 2);
for (byte b : digest) {
hex.append(byteToHexStri... |
requireNonNull(stream, "The stream should not be null");
requireNonNull(messageDigest, "The digest should not be null");
requireNonNull(expected, "The expected should not be null");
messageDigest.reset();
byte[] buffer = new byte[BUFFER_SIZE];
int len;
while ((len = stream.read(buffer)) > 0... | 281 | 177 | 458 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Doubles.java | Doubles | absDiff | class Doubles extends RealNumbers<Double> {
private static final Doubles INSTANCE = new Doubles();
/**
* Returns the singleton instance of this class based on {@link StandardComparisonStrategy}.
*
* @return the singleton instance of this class based on {@link StandardComparisonStrategy}.
*/
public s... |
return isNanOrInfinite(actual) || isNanOrInfinite(other)
? abs(actual - other)
: abs(absBigDecimalDiff(actual, other).doubleValue());
| 405 | 52 | 457 | <methods>public void assertIsFinite(org.assertj.core.api.AssertionInfo, java.lang.Double) ,public void assertIsInfinite(org.assertj.core.api.AssertionInfo, java.lang.Double) ,public void assertIsNaN(org.assertj.core.api.AssertionInfo, java.lang.Double) ,public void assertIsNotFinite(org.assertj.core.api.AssertionInfo, ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/ElementsSatisfyingConsumer.java | ElementsSatisfyingConsumer | withoutElement | class ElementsSatisfyingConsumer<E> {
private final List<E> elements;
ElementsSatisfyingConsumer(Iterable<? extends E> actual, Consumer<? super E> assertions) {
this(filterByPassingAssertions(actual, assertions));
}
private static <E> List<E> filterByPassingAssertions(Iterable<? extends E> actual, Consum... |
ArrayList<E> listWithoutElement = new ArrayList<>(elements);
removeFirstReference(element, listWithoutElement);
return new ElementsSatisfyingConsumer<>(listWithoutElement);
| 357 | 47 | 404 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/ErrorMessages.java | ErrorMessages | endDateToCompareActualWithIsNull | class ErrorMessages {
public static String arrayIsNull() {
return "The given array should not be null";
}
public static String arrayIsEmpty() {
return "The given array should not be empty";
}
public static String iterableIsNull() {
return "The given iterable should not be null";
}
public s... |
return "The end date of period to compare actual with should not be null";
| 1,076 | 21 | 1,097 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/ExtendedByTypesComparator.java | ExtendedByTypesComparator | compare | class ExtendedByTypesComparator implements Comparator<Object> {
private final Comparator<Object> comparator;
private final TypeComparators comparatorsByType;
public ExtendedByTypesComparator(TypeComparators comparatorsByType) {
this(
new Comparator<Object>() {
@Override
public... |
// value returned is not relevant for ordering if objects are not equal
if (actual == null && other == null) return 0;
if (actual == null || other == null) return NOT_EQUAL;
@SuppressWarnings("rawtypes")
Comparator comparatorByType = comparatorsByType == null ? null : comparatorsByType.getComparat... | 361 | 164 | 525 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/FieldByFieldComparator.java | FieldByFieldComparator | compare | class FieldByFieldComparator implements Comparator<Object> {
protected final Map<String, Comparator<?>> comparatorsByPropertyOrField;
protected final TypeComparators comparatorsByType;
public FieldByFieldComparator(Map<String, Comparator<?>> comparatorsByPropertyOrField,
TypeComp... |
if (actual == null && other == null) return 0;
if (actual == null || other == null) return NOT_EQUAL;
// value returned is not relevant for ordering if objects are not equal.
return areEqual(actual, other) ? 0 : NOT_EQUAL;
| 705 | 74 | 779 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Floats.java | Floats | absDiff | class Floats extends RealNumbers<Float> {
private static final Floats INSTANCE = new Floats();
/**
* Returns the singleton instance of this class based on {@link StandardComparisonStrategy}.
*
* @return the singleton instance of this class based on {@link StandardComparisonStrategy}.
*/
public stati... |
return isNanOrInfinite(actual) || isNanOrInfinite(other)
? abs(actual - other)
: abs(absBigDecimalDiff(actual, other).floatValue());
| 414 | 52 | 466 | <methods>public void assertIsFinite(org.assertj.core.api.AssertionInfo, java.lang.Float) ,public void assertIsInfinite(org.assertj.core.api.AssertionInfo, java.lang.Float) ,public void assertIsNaN(org.assertj.core.api.AssertionInfo, java.lang.Float) ,public void assertIsNotFinite(org.assertj.core.api.AssertionInfo, jav... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Futures.java | Futures | assertSucceededWithin | class Futures {
private static final Futures INSTANCE = new Futures();
/**
* Returns the singleton instance of this class.
*
* @return the singleton instance of this class.
*/
public static Futures instance() {
return INSTANCE;
}
@VisibleForTesting
Failures failures = Failures.instance();... |
assertNotNull(info, actual);
try {
return actual.get(timeout.toNanos(), TimeUnit.NANOSECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException | CancellationException e) {
throw failures.failure(info, shouldBeCompletedWithin(actual, timeout, e));
}
| 957 | 90 | 1,047 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/IgnoringFieldsComparator.java | IgnoringFieldsComparator | areEqual | class IgnoringFieldsComparator extends FieldByFieldComparator {
private final String[] fields;
public IgnoringFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyOrField,
TypeComparators comparatorByType, String... fields) {
super(comparatorByPropertyOrField, comp... |
try {
return Objects.instance().areEqualToIgnoringGivenFields(actualElement, otherElement, comparatorsByPropertyOrField,
comparatorsByType, fields);
} catch (IntrospectionError e) {
return false;
}
| 248 | 66 | 314 | <methods>public void <init>(Map<java.lang.String,Comparator<?>>, org.assertj.core.internal.TypeComparators) ,public void <init>() ,public int compare(java.lang.Object, java.lang.Object) ,public java.lang.String toString() <variables>protected final non-sealed Map<java.lang.String,Comparator<?>> comparatorsByPropertyOrF... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/IndexedDiff.java | IndexedDiff | equals | class IndexedDiff {
public final Object actual;
public final Object expected;
public final int index;
/**
* Create a {@link IndexedDiff}.
* @param actual the actual value of the diff.
* @param expected the expected value of the diff.
* @param index the index the diff occurred at.
*/
public Ind... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IndexedDiff that = (IndexedDiff) o;
return index == that.index && Objects.equals(actual, that.actual) && Objects.equals(expected, that.expected);
| 242 | 81 | 323 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/InputStreams.java | InputStreams | assertHasBinaryContent | class InputStreams {
private static final InputStreams INSTANCE = new InputStreams();
/**
* Returns the singleton instance of this class.
* @return the singleton instance of this class.
*/
public static InputStreams instance() {
return INSTANCE;
}
@VisibleForTesting
Diff diff = new Diff();
... |
requireNonNull(expected, "The binary content to compare to should not be null");
assertNotNull(info, actual);
try {
BinaryDiffResult result = binaryDiff.diff(actual, expected);
if (result.hasNoDiff()) return;
throw failures.failure(info, shouldHaveBinaryContent(actual, result));
} cat... | 1,418 | 128 | 1,546 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/IterableDiff.java | IterableDiff | isActualElementInExpected | class IterableDiff<T> {
private final ComparisonStrategy comparisonStrategy;
List<T> unexpected;
List<T> missing;
IterableDiff(Iterable<T> actual, Iterable<T> expected, ComparisonStrategy comparisonStrategy) {
this.comparisonStrategy = comparisonStrategy;
// return the elements in actual that are not... |
// the order of comparisonStrategy.areEqual is important if element comparison is not symmetrical, we must compare actual to
// expected but not expected to actual, for ex recursive comparison where:
// - actual element is PersonDto, expected a list of Person
// - Person has more fields than PersonDto ... | 822 | 148 | 970 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/IterableElementComparisonStrategy.java | IterableElementComparisonStrategy | areEqual | class IterableElementComparisonStrategy<T> extends StandardComparisonStrategy {
private final Comparator<? super T> elementComparator;
public IterableElementComparisonStrategy(Comparator<? super T> elementComparator) {
this.elementComparator = elementComparator;
}
@SuppressWarnings("unchecked")
@Overri... |
if (actual == null && other == null) return true;
if (actual == null || other == null) return false;
// expecting actual and other to be iterable<T>
return actual instanceof Iterable && other instanceof Iterable
&& compareElementsOf((Iterable<T>) actual, (Iterable<T>) other);
| 365 | 83 | 448 | <methods>public boolean areEqual(java.lang.Object, java.lang.Object) ,public Iterable<?> duplicatesFrom(Iterable<?>) ,public static org.assertj.core.internal.StandardComparisonStrategy instance() ,public boolean isGreaterThan(java.lang.Object, java.lang.Object) ,public boolean isLessThan(java.lang.Object, java.lang.Obj... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/ObjectArrayElementComparisonStrategy.java | ObjectArrayElementComparisonStrategy | areEqual | class ObjectArrayElementComparisonStrategy<T> extends StandardComparisonStrategy {
private final Comparator<? super T> elementComparator;
public ObjectArrayElementComparisonStrategy(Comparator<? super T> elementComparator) {
this.elementComparator = elementComparator;
}
@SuppressWarnings("unchecked")
@... |
if (actual == null && other == null) return true;
if (actual == null || other == null) return false;
// expecting actual and other to be T[]
return isArray(actual) && isArray(other) && compareElementsOf((T[]) actual, (T[]) other);
| 339 | 74 | 413 | <methods>public boolean areEqual(java.lang.Object, java.lang.Object) ,public Iterable<?> duplicatesFrom(Iterable<?>) ,public static org.assertj.core.internal.StandardComparisonStrategy instance() ,public boolean isGreaterThan(java.lang.Object, java.lang.Object) ,public boolean isLessThan(java.lang.Object, java.lang.Obj... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/OnFieldsComparator.java | OnFieldsComparator | areEqual | class OnFieldsComparator extends FieldByFieldComparator {
private final String[] fields;
public OnFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyOrField,
TypeComparators comparatorByType, String... fields) {
super(comparatorByPropertyOrField, comparatorByType);
... |
try {
return Objects.instance().areEqualToComparingOnlyGivenFields(actualElement, otherElement,
comparatorsByPropertyOrField, comparatorsByType,
fields);
} catch (Introspe... | 390 | 70 | 460 | <methods>public void <init>(Map<java.lang.String,Comparator<?>>, org.assertj.core.internal.TypeComparators) ,public void <init>() ,public int compare(java.lang.Object, java.lang.Object) ,public java.lang.String toString() <variables>protected final non-sealed Map<java.lang.String,Comparator<?>> comparatorsByPropertyOrF... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Predicates.java | Predicates | assertIsNotNull | class Predicates {
private static final Predicates INSTANCE = new Predicates();
/**
* Returns the singleton instance of this class.
* @return the singleton instance of this class.
*/
public static Predicates instance() {
return INSTANCE;
}
@VisibleForTesting
Failures failures = Failures.inst... |
requireNonNull(predicate, "The predicate to evaluate should not be null");
| 207 | 22 | 229 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/RealNumbers.java | RealNumbers | absBigDecimalDiff | class RealNumbers<NUMBER extends Number & Comparable<NUMBER>> extends Numbers<NUMBER> {
protected RealNumbers() {
super();
}
protected RealNumbers(ComparisonStrategy comparisonStrategy) {
super(comparisonStrategy);
}
/**
* Verifies that the actual value is equal to {@code NaN}.<br>
* It does ... |
BigDecimal number1AsbigDecimal = new BigDecimal(String.valueOf(number1));
BigDecimal number2AsbigDecimal = new BigDecimal(String.valueOf(number2));
return number1AsbigDecimal.subtract(number2AsbigDecimal).abs();
| 813 | 76 | 889 | <methods>public void <init>() ,public void <init>(org.assertj.core.internal.ComparisonStrategy) ,public void assertIsBetween(org.assertj.core.api.AssertionInfo, NUMBER, NUMBER, NUMBER) ,public void assertIsCloseTo(org.assertj.core.api.AssertionInfo, NUMBER, NUMBER, Offset<NUMBER>) ,public void assertIsCloseToPercentage... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/RecursiveHelper.java | RecursiveHelper | isContainer | class RecursiveHelper {
public static boolean isContainer(Object o) {<FILL_FUNCTION_BODY>}
} |
return o instanceof Iterable ||
o instanceof Map ||
o instanceof Optional ||
o instanceof AtomicReference ||
o instanceof AtomicReferenceArray ||
o instanceof AtomicBoolean ||
o instanceof AtomicInteger ||
o instanceof AtomicIntegerArray ... | 33 | 89 | 122 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Spliterators.java | Spliterators | characteristicNames | class Spliterators {
/**
* Name for constant {@link Spliterator#DISTINCT}
*/
private static final String SPLITERATOR_DISTINCT = "DISTINCT";
/**
* Name for constant {@link Spliterator#SORTED}
*/
private static final String SPLITERATOR_SORTED = "SORTED";
/**
* Name for constant {@link Spliterator... |
Set<String> names = new HashSet<>();
if (hasCharacteristic(characteristics, Spliterator.DISTINCT)) names.add(SPLITERATOR_DISTINCT);
if (hasCharacteristic(characteristics, Spliterator.SORTED)) names.add(SPLITERATOR_SORTED);
if (hasCharacteristic(characteristics, Spliterator.ORDERED)) names.add(SPLITERAT... | 1,080 | 289 | 1,369 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/StandardComparisonStrategy.java | StandardComparisonStrategy | areEqual | class StandardComparisonStrategy extends AbstractComparisonStrategy {
private static final StandardComparisonStrategy INSTANCE = new StandardComparisonStrategy();
/**
* Returns the singleton instance of this class.
*
* @return the singleton instance of this class.
*/
public static StandardComparison... |
if (actual == null) return other == null;
Class<?> actualClass = actual.getClass();
if (actualClass.isArray() && other != null) {
Class<?> otherClass = other.getClass();
if (otherClass.isArray()) {
if (actualClass.getComponentType().isPrimitive() && otherClass.getComponentType().isPrimi... | 1,540 | 453 | 1,993 | <methods>public non-sealed void <init>() ,public boolean arrayContains(java.lang.Object, java.lang.Object) ,public Iterable<?> duplicatesFrom(Iterable<?>) ,public boolean isGreaterThanOrEqualTo(java.lang.Object, java.lang.Object) ,public boolean isLessThan(java.lang.Object, java.lang.Object) ,public boolean isLessThanO... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/TypeComparators.java | TypeComparators | defaultTypeComparators | class TypeComparators extends TypeHolder<Comparator<?>> {
private static final double DOUBLE_COMPARATOR_PRECISION = 1e-15;
private static final DoubleComparator DEFAULT_DOUBLE_COMPARATOR = new DoubleComparator(DOUBLE_COMPARATOR_PRECISION);
private static final float FLOAT_COMPARATOR_PRECISION = 1e-6f;
private... |
TypeComparators comparatorByType = new TypeComparators();
comparatorByType.registerComparator(Double.class, DEFAULT_DOUBLE_COMPARATOR);
comparatorByType.registerComparator(Float.class, DEFAULT_FLOAT_COMPARATOR);
comparatorByType.registerComparator(Path.class, DEFAULT_PATH_COMPARATOR);
return compar... | 713 | 104 | 817 | <methods>public void <init>() ,public void <init>(Comparator<Class<?>>) ,public void clear() ,public Stream<Entry<Class<?>,Comparator<?>>> entityByTypes() ,public boolean equals(java.lang.Object) ,public Comparator<?> get(Class<?>) ,public boolean hasEntity(Class<?>) ,public int hashCode() ,public boolean isEmpty() ,pu... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Uris.java | Uris | assertHasNoParameters | class Uris {
private static final String UTF_8 = "UTF-8";
private static final String EQUAL = "=";
private static final String AND = "&";
private static final Uris INSTANCE = new Uris();
@VisibleForTesting
Failures failures = Failures.instance();
public static Uris instance() {
return INSTANCE;
... |
assertNotNull(info, actual);
Map<String, List<String>> parameters = getParameters(actual.getRawQuery());
if (!parameters.isEmpty()) throw failures.failure(info, shouldHaveNoParameters(actual, parameters.keySet()));
| 1,518 | 62 | 1,580 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/internal/Urls.java | Urls | assertHasParameter | class Urls {
private static final Urls INSTANCE = new Urls();
@VisibleForTesting
Failures failures = Failures.instance();
public static Urls instance() {
return INSTANCE;
}
Urls() {}
private static String extractNonQueryParams(URL url) {
String queryPart = url.getQuery() == null ? "" : url.ge... |
assertNotNull(info, actual);
Map<String, List<String>> parameters = getParameters(actual.getQuery());
if (!parameters.containsKey(expectedParameterName))
throw failures.failure(info, shouldHaveParameter(actual, expectedParameterName, expectedParameterValue));
List<String> values = parameters.g... | 1,372 | 126 | 1,498 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/matcher/AssertionMatcher.java | AssertionMatcher | matches | class AssertionMatcher<T> extends BaseMatcher<T> {
private AssertionError firstError;
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public boolean matches(Object argument) {<FILL_FUNCTION_BODY>}
/**
* Perform the assertions implemented in this method when the {@link AssertionMat... |
T actual = (T) argument;
try {
assertion(actual);
return true;
} catch (AssertionError e) {
firstError = e;
return false;
}
| 421 | 54 | 475 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/presentation/BinaryRepresentation.java | BinaryRepresentation | toStringOf | class BinaryRepresentation extends StandardRepresentation {
public static final BinaryRepresentation BINARY_REPRESENTATION = new BinaryRepresentation();
public static final String BYTE_PREFIX = "0b";
/**
* Returns binary the {@code toString} representation of the given object. It may or not the object's own... |
if (number instanceof Byte) return toStringOf((Byte) number);
if (number instanceof Short) return toStringOf((Short) number);
if (number instanceof Integer) return toStringOf((Integer) number);
if (number instanceof Long) return toStringOf((Long) number);
if (number instanceof Float) return toStrin... | 684 | 119 | 803 | <methods>public non-sealed void <init>() ,public static int getMaxElementsForPrinting() ,public static int getMaxLengthForSingleLineDescription() ,public static int getMaxStackTraceElementsDisplayed() ,public static void registerFormatterForType(Class<T>, Function<T,java.lang.String>) ,public static void removeAllRegis... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/presentation/CompositeRepresentation.java | CompositeRepresentation | toStringOf | class CompositeRepresentation implements Representation {
private final List<Representation> representations;
public CompositeRepresentation(List<Representation> representations) {
if (representations == null) throw new IllegalArgumentException("The given representations should not be null");
this.represe... |
// don't create streams for performance reasons and because this code is simple enough (even not as elegant as with stream)
for (Representation representation : representations) {
String value = representation.toStringOf(object);
if (value != null) return value;
}
return STANDARD_REPRESENTA... | 369 | 87 | 456 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/presentation/HexadecimalRepresentation.java | HexadecimalRepresentation | toStringOf | class HexadecimalRepresentation extends StandardRepresentation {
public static final HexadecimalRepresentation HEXA_REPRESENTATION = new HexadecimalRepresentation();
public static final String PREFIX = "0x";
public static final int NIBBLE_SIZE = 4;
/**
* Returns hexadecimal the {@code toString} representa... |
if (hasCustomFormatterFor(object)) return customFormat(object);
if (object instanceof Number) return toStringOf((Number) object);
else if (object instanceof String) return toStringOf(this, (String) object);
else if (object instanceof Character) return toStringOf((Character) object);
return super.to... | 713 | 87 | 800 | <methods>public non-sealed void <init>() ,public static int getMaxElementsForPrinting() ,public static int getMaxLengthForSingleLineDescription() ,public static int getMaxStackTraceElementsDisplayed() ,public static void registerFormatterForType(Class<T>, Function<T,java.lang.String>) ,public static void removeAllRegis... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/presentation/NumberGrouping.java | NumberGrouping | toHexLiteral | class NumberGrouping {
private static final String UNDERSCORE_SEPARATOR = "_";
private static Pattern hexGroupPattern = Pattern.compile("([0-9|A-Z]{4})");
private static Pattern binaryGroupPattern = Pattern.compile("([0-1]{8})");
static String toHexLiteral(String value) {
return value.length() > 4 ? toHex... |
Matcher matcher = pattern.matcher(value);
StringBuilder literalBuilder = new StringBuilder();
while (matcher.find()) {
String byteGroup = matcher.group(1);
if (notEmpty(literalBuilder)) {
literalBuilder.append(UNDERSCORE_SEPARATOR);
}
literalBuilder.append(byteGroup);
}... | 216 | 105 | 321 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/presentation/PredicateDescription.java | PredicateDescription | equals | class PredicateDescription {
private static final String DEFAULT = "given";
public static final PredicateDescription GIVEN = new PredicateDescription(DEFAULT);
// can be public as it is immutable, never null
public final String description;
/**
* Build a {@link PredicateDescription}.
*
* @param des... |
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
PredicateDescription description = (PredicateDescription) obj;
return deepEquals(this.description, description.description);
| 211 | 76 | 287 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/presentation/RotatingQueue.java | RotatingQueue | offer | class RotatingQueue<T> extends AbstractQueue<T> {
/** The array to provide a view of. */
private final Queue<T> data;
/** The maximum number of elements that can be present. */
private final int capacity;
/**
* Creates a new {@link RotatingQueue}.
*
* @param capacity the maximum number of elements ... |
if (capacity == 0) return false;
if (data.size() == capacity) data.remove();
return data.add(element);
| 293 | 39 | 332 | <methods>public boolean add(T) ,public boolean addAll(Collection<? extends T>) ,public void clear() ,public T element() ,public T remove() <variables> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/presentation/UnicodeRepresentation.java | UnicodeRepresentation | escapeUnicode | class UnicodeRepresentation extends StandardRepresentation {
public static final UnicodeRepresentation UNICODE_REPRESENTATION = new UnicodeRepresentation();
/**
* Returns hexadecimal the {@code toString} representation of the given String or Character.
*
* @param object the given object.
* @return the... |
StringBuilder b = new StringBuilder(input.length());
Formatter formatter = new Formatter(b);
for (char c : input.toCharArray()) {
if (c < 128) {
b.append(c);
} else {
formatter.format("\\u%04x", (int) c);
}
}
formatter.close();
return b.toString();
| 270 | 107 | 377 | <methods>public non-sealed void <init>() ,public static int getMaxElementsForPrinting() ,public static int getMaxLengthForSingleLineDescription() ,public static int getMaxStackTraceElementsDisplayed() ,public static void registerFormatterForType(Class<T>, Function<T,java.lang.String>) ,public static void removeAllRegis... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/ArrayWrapperList.java | ArrayWrapperList | wrap | class ArrayWrapperList extends AbstractList<Object> {
/**
* Wraps a given array with a <code>{@link ArrayWrapperList}</code>
*
* @param array the array to wrap.
* @return the wrapped array or {@code null} if the given array was already {@code null}.
* @throws IllegalArgumentException if the {@code arr... |
if (array == null) {
return null;
}
checkArgument(array.getClass().isArray(), "The object to wrap should be an array");
return new ArrayWrapperList(array);
| 410 | 53 | 463 | <methods>public boolean add(java.lang.Object) ,public void add(int, java.lang.Object) ,public boolean addAll(int, Collection<? extends java.lang.Object>) ,public void clear() ,public boolean equals(java.lang.Object) ,public abstract java.lang.Object get(int) ,public int hashCode() ,public int indexOf(java.lang.Object) ... |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Arrays.java | Arrays | sizeOf | class Arrays {
/**
* Indicates whether the given object is not {@code null} and is an array.
*
* @param o the given object.
* @return {@code true} if the given object is not {@code null} and is an array, otherwise {@code false}.
*/
public static boolean isArray(Object o) {
return o != null && o.... |
if (!isArray(array)) throw new IllegalArgumentException(format("expecting %s to be an array", array));
if (array instanceof Object[]) return ((Object[]) array).length;
return getLength(array);
| 1,814 | 56 | 1,870 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Closeables.java | Closeables | closeCloseable | class Closeables {
private static final Logger logger = Logger.getLogger(Closeables.class.getCanonicalName());
/**
* Closes the given {@link Closeable}s, ignoring any thrown exceptions.
*
* @param closeables the {@code Closeable}s to close.
*/
public static void closeQuietly(Closeable... closeables)... |
if (c == null) {
return;
}
try {
c.close();
} catch (Throwable t) {
logger.log(Level.WARNING, "Error occurred while closing " + c, t);
}
| 158 | 63 | 221 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/DoubleComparator.java | DoubleComparator | equals | class DoubleComparator extends NullSafeComparator<Double> {
private double precision;
public DoubleComparator(double epsilon) {
this.precision = epsilon;
}
@Override
protected int compareNonNull(Double x, Double y) {
if (closeEnough(x, y, precision)) return 0;
return x < y ? -1 : 1;
}
publ... |
if (this == obj) return true;
if (obj == null) return false;
if (!(obj instanceof DoubleComparator)) return false;
DoubleComparator other = (DoubleComparator) obj;
return Double.doubleToLongBits(precision) == Double.doubleToLongBits(other.precision);
| 313 | 84 | 397 | <methods>public int compare(java.lang.Double, java.lang.Double) <variables> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/FloatComparator.java | FloatComparator | closeEnough | class FloatComparator extends NullSafeComparator<Float> {
private float precision;
public FloatComparator(float epsilon) {
this.precision = epsilon;
}
public float getEpsilon() {
return precision;
}
@Override
public int compareNonNull(Float x, Float y) {
if (closeEnough(x, y, precision)) r... |
return x.floatValue() == y.floatValue() || Math.abs(x - y) <= epsilon;
| 333 | 30 | 363 | <methods>public int compare(java.lang.Float, java.lang.Float) <variables> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Hexadecimals.java | Hexadecimals | byteToHexString | class Hexadecimals {
protected static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
public static String byteToHexString(byte b) {<FILL_FUNCTION_BODY>}
public static String toHexString(byte... bytes) {
StringBuilder stringBuilder = new StringBuilder();
for (byte b : bytes)
stringBuil... |
int v = b & 0xFF;
return new String(new char[] { HEX_ARRAY[v >>> 4], HEX_ARRAY[v & 0x0F] });
| 147 | 52 | 199 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/IterableUtil.java | IterableUtil | isNullOrEmpty | class IterableUtil {
/**
* Indicates whether the given {@link Iterable} is {@code null} or empty.
*
* @param iterable the given {@code Iterable} to check.
* @return {@code true} if the given {@code Iterable} is {@code null} or empty, otherwise {@code false}.
*/
public static boolean isNullOrEmpty(I... |
if (iterable == null) return true;
if (iterable instanceof Collection && ((Collection<?>) iterable).isEmpty()) return true;
return !iterable.iterator().hasNext();
| 1,167 | 50 | 1,217 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Lists.java | Lists | newArrayList | class Lists {
@SafeVarargs
public static <T> List<T> list(T... elements) {
return newArrayList(elements);
}
/**
* Creates a <em>mutable</em> {@link ArrayList} containing the given elements.
*
* @param <T> the generic type of the {@code ArrayList} to create.
* @param elements the elements to st... |
if (elements == null) {
return null;
}
return Streams.stream(elements).collect(toCollection(ArrayList::new));
| 711 | 39 | 750 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Maps.java | Maps | newHashMap | class Maps {
/**
* Returns the {@code String} {@link org.assertj.core.presentation.StandardRepresentation standard representation} of
* the given map, or {@code null} if the given map is {@code null}.
*
* @param map the map to format.
* @return the {@code String} representation of the given map.
*... |
Map<K, V> map = new HashMap<>();
map.put(key, value);
return map;
| 362 | 33 | 395 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/NullSafeComparator.java | NullSafeComparator | compare | class NullSafeComparator<T> implements Comparator<T> {
@Override
public int compare(T o1, T o2) {<FILL_FUNCTION_BODY>}
protected abstract int compareNonNull(T o1, T o2);
} |
if (o1 == o2) return 0;
if (o1 == null) return -1;
if (o2 == null) return 1;
return compareNonNull(o1, o2);
| 70 | 57 | 127 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Objects.java | Objects | namesOf | class Objects {
/** Prime number used to calculate the hash code of objects. */
public static final int HASH_CODE_PRIME = 31;
/**
* Returns {@code true} if the arguments are deeply equal to each other, {@code false} otherwise.
* <p>
* Two {@code null} values are deeply equal. If both arguments are arra... |
if (isNullOrEmpty(types)) {
return new String[0];
}
String[] names = new String[types.length];
for (int i = 0; i < types.length; i++) {
names[i] = types[i].getName();
}
return names;
| 953 | 79 | 1,032 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Preconditions.java | Preconditions | checkNotNullOrEmpty | class Preconditions {
public static final String ARGUMENT_EMPTY = "Argument expected not to be empty!";
/**
* Verifies that the given {@code CharSequence} is not {@code null} or empty.
*
* @param s the given {@code CharSequence}.
* @return the validated {@code CharSequence}.
* @throws NullPointerEx... |
requireNonNull(s, message);
if (s.length() == 0) throwExceptionForBeingEmpty(message);
return s;
| 1,663 | 37 | 1,700 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Sets.java | Sets | newHashSet | class Sets {
/**
* Creates a <em>mutable</em> {@link LinkedHashSet} containing the given elements.
*
* @param <T> the generic type of the {@code HashSet} to create.
* @param elements the elements to store in the {@code HashSet}.
* @return the created {@code HashSet}, or {@code null} if the given array... |
if (elements == null) {
return null;
}
return Streams.stream(elements).collect(toCollection(HashSet::new));
| 937 | 40 | 977 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/Streams.java | Streams | stream | class Streams {
/**
* Returns a sequential {@link Stream} of the contents of {@code iterable}, delegating to {@link
* Collection#stream} if possible.
* @param <T> the stream type
* @param iterable the iterable to built the stream from
* @return the stream built from the given {@link Iterable}
*/
... |
return (iterable instanceof Collection)
? ((Collection<T>) iterable).stream()
: StreamSupport.stream(iterable.spliterator(), false);
| 175 | 42 | 217 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/TextFileWriter.java | TextFileWriter | write | class TextFileWriter {
private static final TextFileWriter INSTANCE = new TextFileWriter();
public static TextFileWriter instance() {
return INSTANCE;
}
public void write(File file, String... content) throws IOException {
write(file, Charset.defaultCharset(), content);
}
public void write(File fi... |
try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), charset))) {
for (String line : content) {
writer.println(line);
}
}
| 123 | 53 | 176 | <no_super_class> |
assertj_assertj | assertj/assertj-core/src/main/java/org/assertj/core/util/URLs.java | URLs | contentOf | class URLs {
private URLs() {}
/**
* Loads the text content of a URL into a character string.
*
* @param url the URL.
* @param charsetName the name of the character set to use.
* @return the content of the file.
* @throws IllegalArgumentException if the given character set is not supported on th... |
requireNonNull(charset, "The charset should not be null");
try {
return loadContents(url.openStream(), charset);
} catch (IOException e) {
throw new UncheckedIOException("Unable to read " + url, e);
}
| 895 | 68 | 963 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.