Skip to content

Commit

Permalink
Deprecate usages of InstanceOfAssertFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-krecan committed Feb 16, 2022
1 parent 5f946bd commit d9274fe
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import net.javacrumbs.jsonunit.core.Configuration;
import net.javacrumbs.jsonunit.core.internal.Diff;
import net.javacrumbs.jsonunit.core.internal.Path;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.FactoryBasedNavigableListAssert;
import org.assertj.core.api.InstanceOfAssertFactory;
import org.assertj.core.error.BasicErrorMessageFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -65,6 +67,48 @@ protected JsonListAssert newAbstractIterableAssert(Iterable<?> iterable) {
return new JsonListAssert(newArrayList(iterable), path, configuration);
}

/**
* @deprecated InstanceOfAssertFactory is not supported with JsonUnit
*/
@Override
@Deprecated
public <ASSERT extends AbstractAssert<?, ?>> ASSERT element(int index, InstanceOfAssertFactory<?, ASSERT> assertFactory) {
return super.element(index, assertFactory);
}

/**
* @deprecated InstanceOfAssertFactory is not supported with JsonUnit
*/
@Override
@Deprecated
public <ASSERT extends AbstractAssert<?, ?>> ASSERT singleElement(InstanceOfAssertFactory<?, ASSERT> assertFactory) {
return super.singleElement(assertFactory);
}

@Override
public <ASSERT extends AbstractAssert<?, ?>> ASSERT asInstanceOf(InstanceOfAssertFactory<?, ASSERT> instanceOfAssertFactory) {
throw failure("Please use isString(), isNumber(), isBoolean(), isNull(), isUri(), isArray() or isObject().%n"
+ "This method will most likely not provide the result you expect it to.");
}

/**
* @deprecated InstanceOfAssertFactory is not supported with JsonUnit
*/
@Override
@Deprecated
public <ASSERT extends AbstractAssert<?, ?>> ASSERT first(InstanceOfAssertFactory<?, ASSERT> assertFactory) {
return super.first(assertFactory);
}

/**
* @deprecated InstanceOfAssertFactory is not supported with JsonUnit
*/
@Override
@Deprecated
public <ASSERT extends AbstractAssert<?, ?>> ASSERT last(InstanceOfAssertFactory<?, ASSERT> assertFactory) {
return super.last(assertFactory);
}

@NotNull
private Diff createDiff(Object other) {
return Diff.create(other, wrapDeserializedObject(actual), "fullJson", path, configuration);
Expand Down

0 comments on commit d9274fe

Please # to comment.