diff --git a/confidence-core/src/main/java/org/saynotobugs/confidence/assessment/FailPrepended.java b/confidence-core/src/main/java/org/saynotobugs/confidence/assessment/FailPrepended.java index f7d81f6b..650e6686 100644 --- a/confidence-core/src/main/java/org/saynotobugs/confidence/assessment/FailPrepended.java +++ b/confidence-core/src/main/java/org/saynotobugs/confidence/assessment/FailPrepended.java @@ -25,7 +25,10 @@ /** * A {@link Assessment} that prepends any mismatch {@link Description}. + * + * @deprecated use {@link DescriptionUpdated} to update pass and fail description. */ +@Deprecated public final class FailPrepended extends AssessmentComposition { public FailPrepended(Description prefix, Assessment delegate) diff --git a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/composite/DescribedAs.java b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/composite/DescribedAs.java index 02f32670..6655cd8f 100644 --- a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/composite/DescribedAs.java +++ b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/composite/DescribedAs.java @@ -25,7 +25,6 @@ import org.saynotobugs.confidence.Description; import org.saynotobugs.confidence.Quality; import org.saynotobugs.confidence.assessment.DescriptionUpdated; -import org.saynotobugs.confidence.assessment.FailUpdated; @StaticFactories( @@ -34,33 +33,19 @@ deprecates = @DeprecatedFactories(value = "Core", packageName = "org.saynotobugs.confidence.quality")) public final class DescribedAs extends QualityComposition { + /** + * A {@link Quality} like the delegate {@link Quality} but with updated descriptions. + *

+ * This constructor applies the same function to all three descriptions. + */ public DescribedAs( Function descriptionUpdate, Quality delegate) { - this(descriptionUpdate, descriptionUpdate, delegate); - } - - - public DescribedAs( - Function mismatchUpdate, - Function expectationUpdate, - Quality delegate) - { - super( - actual -> new FailUpdated(mismatchUpdate, delegate.assessmentOf(actual)), - expectationUpdate.value(delegate.description())); - } - - - public DescribedAs( - BiFunction mismatchUpdate, - Function expectationUpdate, - Quality delegate) - { - super( - actual -> new FailUpdated(description -> mismatchUpdate.value(actual, description), delegate.assessmentOf(actual)), - expectationUpdate.value(delegate.description())); + this((value, description) -> descriptionUpdate.value(description), + (value, description) -> descriptionUpdate.value(description), + descriptionUpdate, + delegate); } diff --git a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/file/ContainsData.java b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/file/ContainsData.java index 9810ba14..a7704e43 100644 --- a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/file/ContainsData.java +++ b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/file/ContainsData.java @@ -23,11 +23,12 @@ import org.saynotobugs.confidence.Assessment; import org.saynotobugs.confidence.Description; import org.saynotobugs.confidence.Quality; +import org.saynotobugs.confidence.assessment.DescriptionUpdated; import org.saynotobugs.confidence.assessment.Fail; -import org.saynotobugs.confidence.assessment.FailPrepended; import org.saynotobugs.confidence.description.Spaced; import org.saynotobugs.confidence.description.Text; import org.saynotobugs.confidence.description.Value; +import org.saynotobugs.confidence.description.bifunction.TextAndOriginal; import org.saynotobugs.confidence.quality.object.EqualTo; import java.io.DataInputStream; @@ -60,9 +61,9 @@ public Assessment assessmentOf(File candidate) { byte[] buffer = new byte[(int) candidate.length()]; reader.readFully(buffer); - return new FailPrepended( - new Spaced( - new Text("contained data")), mDelegate.assessmentOf(buffer)); + return new DescriptionUpdated( + new TextAndOriginal<>(new Text("contained data")), + mDelegate.assessmentOf(buffer)); } catch (IOException exception) { diff --git a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/iterable/Each.java b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/iterable/Each.java index e46e3a51..6d5013e4 100644 --- a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/iterable/Each.java +++ b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/iterable/Each.java @@ -28,9 +28,10 @@ import org.saynotobugs.confidence.Assessment; import org.saynotobugs.confidence.Quality; import org.saynotobugs.confidence.assessment.AllPassed; -import org.saynotobugs.confidence.assessment.FailPrepended; +import org.saynotobugs.confidence.assessment.DescriptionUpdated; import org.saynotobugs.confidence.description.Spaced; import org.saynotobugs.confidence.description.Text; +import org.saynotobugs.confidence.description.bifunction.TextAndOriginal; import org.saynotobugs.confidence.quality.composite.AllOf; import org.saynotobugs.confidence.quality.composite.QualityComposition; @@ -64,7 +65,9 @@ public Each(Quality delegate) super(actual -> new AllPassed(new Text("elements ["), EMPTY, new Text("]"), new Collected<>(ArrayList::new, new Mapped, Assessment>( - numberedVerdict -> new FailPrepended(new Text(numberedVerdict.left() + ":"), numberedVerdict.right()), + numberedVerdict -> new DescriptionUpdated( + new TextAndOriginal<>(numberedVerdict.left() + ":"), + numberedVerdict.right()), new Numbered<>(new Mapped<>(delegate::assessmentOf, actual)))).value()), new Spaced(new Text("each element"), delegate.description())); } diff --git a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/object/EqualTo.java b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/object/EqualTo.java index 24370003..dc8a477d 100644 --- a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/object/EqualTo.java +++ b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/object/EqualTo.java @@ -22,11 +22,12 @@ import org.dmfs.srcless.annotations.staticfactory.DeprecatedFactories; import org.dmfs.srcless.annotations.staticfactory.StaticFactories; import org.saynotobugs.confidence.Quality; -import org.saynotobugs.confidence.assessment.FailPrepended; +import org.saynotobugs.confidence.assessment.DescriptionUpdated; import org.saynotobugs.confidence.assessment.PassIf; import org.saynotobugs.confidence.description.Block; import org.saynotobugs.confidence.description.Text; import org.saynotobugs.confidence.description.Value; +import org.saynotobugs.confidence.description.bifunction.TextAndOriginal; import org.saynotobugs.confidence.quality.composite.QualityComposition; import org.saynotobugs.confidence.quality.iterable.Iterates; import org.saynotobugs.confidence.utils.ArrayIterable; @@ -46,8 +47,8 @@ public final class EqualTo extends QualityComposition public EqualTo(T expected) { super(actual -> expected.getClass().isArray() && actual.getClass().isArray() - ? new FailPrepended( - new Text("array that"), + ? new DescriptionUpdated( + new TextAndOriginal<>("array that"), new Iterates<>(new Mapped<>(EqualTo::new, new ArrayIterable(expected))).assessmentOf(new ArrayIterable(actual))) : new PassIf(expected.equals(actual), new Value(actual), new Value(actual)), expected.getClass().isArray() diff --git a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/ContainsText.java b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/ContainsText.java index e425c3be..39148118 100644 --- a/confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/ContainsText.java +++ b/confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/ContainsText.java @@ -23,6 +23,7 @@ import org.saynotobugs.confidence.description.Spaced; import org.saynotobugs.confidence.description.Text; import org.saynotobugs.confidence.description.Value; +import org.saynotobugs.confidence.description.bifunction.TextAndOriginal; import org.saynotobugs.confidence.quality.composite.DescribedAs; import org.saynotobugs.confidence.quality.composite.Has; import org.saynotobugs.confidence.quality.composite.QualityComposition; @@ -54,6 +55,8 @@ public ContainsText(Charset charset, Quality delegate) new Text("contains"), new Text("contained"), path -> new String(Files.readAllBytes(path), charset), - new DescribedAs<>(orig -> new Spaced(new Value(charset.name()), new Text("text"), orig), delegate))); + new DescribedAs<>( + new TextAndOriginal<>(new Spaced(new Value(charset.name()), new Text("text"))), + delegate))); } } diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/consumer/ConsumerThatAcceptsTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/consumer/ConsumerThatAcceptsTest.java index a6ce5a7f..f136ad00 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/consumer/ConsumerThatAcceptsTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/consumer/ConsumerThatAcceptsTest.java @@ -62,7 +62,7 @@ void testSuppliedValue() @Test void testSuppliedValueWithDescription() { - assertThat(new ConsumerThatAccepts<>(new Text("Pass"), new Text("Fail"),new Text("Consumes"), () -> "a"), + assertThat(new ConsumerThatAccepts<>(new Text("Pass"), new Text("Fail"), new Text("Consumes"), () -> "a"), new AllOf<>( new Passes<>(x -> {}, "Pass"), new Fails<>(x -> {throw new RuntimeException();}, "Fail "), diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/file/ContainsDataTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/file/ContainsDataTest.java index 97b41247..bce5b0b4 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/file/ContainsDataTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/file/ContainsDataTest.java @@ -30,7 +30,7 @@ void test() throws IOException assertThat(new ContainsData(new byte[] { 1, 2, 3 }), new AllOf<>( - new Passes<>(passingFile, "iterated [\n 0: 1\n 1: 2\n 2: 3\n]"), + new Passes<>(passingFile, "contained data array that iterated [\n 0: 1\n 1: 2\n 2: 3\n]"), new Fails<>(emptyFile, "contained data array that iterated [\n 0: missing 1\n 1: missing 2\n 2: missing 3\n]"), new Fails<>(new File(dir, "nonexistent"), new DescribesAs(new MatchesPattern("threw while reading"))), new HasDescription("contains data [\n 1\n 2\n 3\n]"))); diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/file/ContainsFileTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/file/ContainsFileTest.java index cb164f25..38a28350 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/file/ContainsFileTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/file/ContainsFileTest.java @@ -77,7 +77,7 @@ void testDirWithDelegate() throws IOException dir.mkdir(); assertThat(new ContainsFile("someDir", new Is<>(new ADirectory())), new AllOf<>( - new Passes<>(tempDir, new DescribesAs(new MatchesPattern("contained \"someDir\" was directory "))), + new Passes<>(tempDir, new DescribesAs(new MatchesPattern("contained \"someDir\" was directory "))), new Fails<>(file, "contained \"someDir\" was not a directory"), new Fails<>(dir, "contained \"someDir\" was not a directory"), new Fails<>(new File(tempDir, "nonExistentFile"), "contained \"someDir\" was not a directory"), diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/iterable/ContainsNoneOfTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/iterable/ContainsNoneOfTest.java index 41fba1d9..56c53276 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/iterable/ContainsNoneOfTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/iterable/ContainsNoneOfTest.java @@ -38,15 +38,15 @@ void testLiteral() new AllOf<>( new Passes<>(new Seq(), "elements []"), new Passes<>(new Seq<>("1", "2", "3"), "elements [\n" + - " was\n" + + " 0: was\n" + " \"1\"\n" + " \"1\"\n" + " \"1\"\n" + - " was\n" + + " 1: was\n" + " \"2\"\n" + " \"2\"\n" + " \"2\"\n" + - " was\n" + + " 2: was\n" + " \"3\"\n" + " \"3\"\n" + " \"3\"\n" + @@ -72,13 +72,13 @@ void testQuality() new AllOf<>( new Passes>(new Seq<>(), "elements []"), new Passes<>(new Seq<>("1", "2", "3"), "elements [\n" + - " was\n" + + " 0: was\n" + " \"1\" mismatched pattern /[abc]/\n" + " \"1\"\n" + - " was\n" + + " 1: was\n" + " \"2\" mismatched pattern /[abc]/\n" + " \"2\"\n" + - " was\n" + + " 2: was\n" + " \"3\" mismatched pattern /[abc]/\n" + " \"3\"\n" + "]"), @@ -103,13 +103,13 @@ void testQualityIterable() new AllOf<>( new Passes>(new Seq<>(), "elements []"), new Passes<>(new Seq<>("1", "2", "3"), "elements [\n" + - " was\n" + + " 0: was\n" + " \"1\" mismatched pattern /[abc]/\n" + " \"1\"\n" + - " was\n" + + " 1: was\n" + " \"2\" mismatched pattern /[abc]/\n" + " \"2\"\n" + - " was\n" + + " 2: was\n" + " \"3\" mismatched pattern /[abc]/\n" + " \"3\"\n" + "]"), diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/iterable/EachTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/iterable/EachTest.java index 58074501..94aea8e3 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/iterable/EachTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/iterable/EachTest.java @@ -28,14 +28,14 @@ void testSimpleCtor() assertThat(new Each<>(new LessThan<>(3)), new AllOf<>( new Passes<>(asList(0, 1, 2), "elements [\n" + - " 0\n" + - " 1\n" + - " 2\n" + + " 0: 0\n" + + " 1: 1\n" + + " 2: 2\n" + "]"), new Passes<>(asList(0, 0, 0), "elements [\n" + - " 0\n" + - " 0\n" + - " 0\n" + + " 0: 0\n" + + " 1: 0\n" + + " 2: 0\n" + "]"), new Passes>(emptyList(), "elements []"), new Fails<>(asList(1, 4, 2), "elements [\n ...\n 1: 4\n ...\n]"), @@ -50,24 +50,24 @@ void testMultipleCtor() assertThat(new Each<>(new LessThan<>(3), new GreaterThan<>(0)), new AllOf<>( new Passes>(asList(1, 1, 2), "elements [\n" + - " all of\n" + + " 0: all of\n" + " 0: 1\n" + " 1: 1\n" + - " all of\n" + + " 1: all of\n" + " 0: 1\n" + " 1: 1\n" + - " all of\n" + + " 2: all of\n" + " 0: 2\n" + " 1: 2\n" + "]"), new Passes<>(asList(2, 2, 2), "elements [\n" + - " all of\n" + + " 0: all of\n" + " 0: 2\n" + " 1: 2\n" + - " all of\n" + + " 1: all of\n" + " 0: 2\n" + " 1: 2\n" + - " all of\n" + + " 2: all of\n" + " 0: 2\n" + " 1: 2\n" + "]"), diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/map/ContainsEntryTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/map/ContainsEntryTest.java index 39c6d926..1316e456 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/map/ContainsEntryTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/map/ContainsEntryTest.java @@ -26,10 +26,10 @@ void testKeyOnly() assertThat(new ContainsEntry<>("k1"), new AllOf<>( new Passes<>(map1, "contained Entry (\"k1\": )"), - new Fails<>(new HashMap(), "{} did not contain Entry (\"k1\": )"), - new Fails<>(map2, "{ \"k2\": \"v2\" } did not contain Entry (\"k1\": )"), + new Fails<>(new HashMap(), "{} did not contain Entry (\"k1\": )"), + new Fails<>(map2, "{ \"k2\": \"v2\" } did not contain Entry (\"k1\": )"), // new Fails<>(Map.of("k2", "v2"), new DescribesAs("")), - new HasDescription( "contains Entry (\"k1\": )") + new HasDescription("contains Entry (\"k1\": )") )); } @@ -45,10 +45,10 @@ void testKeyQualityOnly() assertThat(new ContainsEntry<>(new EqualTo<>("k1")), new AllOf<>( new Passes<>(map1, "contained Entry (\"k1\": )"), - new Fails<>(new HashMap(), "{} did not contain Entry (\"k1\": )"), - new Fails<>(map2, "{ \"k2\": \"v2\" } did not contain Entry (\"k1\": )"), + new Fails<>(new HashMap(), "{} did not contain Entry (\"k1\": )"), + new Fails<>(map2, "{ \"k2\": \"v2\" } did not contain Entry (\"k1\": )"), // new Fails<>(Map.of("k2", "v2"), new DescribesAs("")), - new HasDescription( "contains Entry (\"k1\": )") + new HasDescription("contains Entry (\"k1\": )") )); } @@ -64,10 +64,10 @@ void testKeyAndValue() assertThat(new ContainsEntry<>("k1", "v1"), new AllOf<>( new Passes<>(map1, "contained Entry (\"k1\": \"v1\")"), - new Fails<>(new HashMap(), "{} did not contain Entry (\"k1\": \"v1\")"), - new Fails<>(map2, "{ \"k2\": \"v2\" } did not contain Entry (\"k1\": \"v1\")"), + new Fails<>(new HashMap(), "{} did not contain Entry (\"k1\": \"v1\")"), + new Fails<>(map2, "{ \"k2\": \"v2\" } did not contain Entry (\"k1\": \"v1\")"), // new Fails<>(Map.of("k2", "v2"), new DescribesAs("")), - new HasDescription( "contains Entry (\"k1\": \"v1\")") + new HasDescription("contains Entry (\"k1\": \"v1\")") )); } @@ -102,10 +102,10 @@ void testKeyQuality() assertThat(new ContainsEntry<>(new EqualTo<>("k1")), new AllOf<>( new Passes<>(map1, "contained Entry (\"k1\": )"), - new Fails<>(new HashMap(), "{} did not contain Entry (\"k1\": )"), - new Fails<>(map2, "{ \"k2\": \"v2\" } did not contain Entry (\"k1\": )"), + new Fails<>(new HashMap(), "{} did not contain Entry (\"k1\": )"), + new Fails<>(map2, "{ \"k2\": \"v2\" } did not contain Entry (\"k1\": )"), // new Fails<>(Map.of("k2", "v2"), new DescribesAs("")), - new HasDescription( "contains Entry (\"k1\": )") + new HasDescription("contains Entry (\"k1\": )") )); } diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/number/CloseToTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/number/CloseToTest.java index 98f1e423..3cbe2db3 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/number/CloseToTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/number/CloseToTest.java @@ -35,7 +35,7 @@ void testDouble1ulp() new AllOf<>( new Passes<>(1.0000000000000001, "1.0d differed from 1.0 by 0.0, which was less than 2.220446049250313E-16"), new Passes<>(0.9999999999999999, "0.9999999999999999d differed from 1.0 by 1E-16, which was less than 2.220446049250313E-16"), - new Fails<>(1.01001d, "1.01001d differed from 1.0 by 0.01001, which exceeded the ε of 2.220446049250313E-16"), + new Fails<>(1.01001d, "1.01001d differed from 1.0 by 0.01001, which exceeded the ε of 2.220446049250313E-16"), new HasDescription("differs from 1.0 by less than 2.220446049250313E-16") )); } diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/object/EqualToTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/object/EqualToTest.java index 4d53c599..b619be1c 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/object/EqualToTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/object/EqualToTest.java @@ -47,7 +47,7 @@ void testArray() { assertThat(new EqualTo<>(new String[] { "1", "2", "3" }), new AllOf<>( - new Passes(new String[] { "1", "2", "3" }, "iterated [\n 0: \"1\"\n 1: \"2\"\n 2: \"3\"\n]"), + new Passes(new String[] { "1", "2", "3" }, "array that iterated [\n 0: \"1\"\n 1: \"2\"\n 2: \"3\"\n]"), new Fails("123", "\"123\""), new Fails<>(new String[] { "1", "2" }, "array that iterated [\n ...\n 2: missing \"3\"\n]"), new HasDescription("[\n \"1\"\n \"2\"\n \"3\"\n]") diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/object/SuccessfullyTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/object/SuccessfullyTest.java index e7b9c7f9..e07dde8b 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/object/SuccessfullyTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/object/SuccessfullyTest.java @@ -35,7 +35,7 @@ class SuccessfullyTest @Test void test() { - assertThat(new Successfully>(new Text("passed"), new Text("failed with"),new Text("passes"), Fragile::value), + assertThat(new Successfully>(new Text("passed"), new Text("failed with"), new Text("passes"), Fragile::value), new AllOf<>( new Passes>(() -> "", "passed"), new Fails<>(() -> {throw new RuntimeException();}, "failed with "), diff --git a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/path/ContainsTextTest.java b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/path/ContainsTextTest.java index 586f08ce..c228f1af 100644 --- a/confidence-core/src/test/java/org/saynotobugs/confidence/quality/path/ContainsTextTest.java +++ b/confidence-core/src/test/java/org/saynotobugs/confidence/quality/path/ContainsTextTest.java @@ -55,7 +55,7 @@ void testWithQuality() throws IOException } assertThat(new ContainsText(UTF_8, new EqualTo<>("0123456789")), new AllOf<>( - new Passes<>(file10Bytes, "contained \"0123456789\""), + new Passes<>(file10Bytes, "contained \"UTF-8\" text \"0123456789\""), new Fails<>(tempDir, new DescribesAs(new MatchesPattern("threw ]+>"))), new Fails<>(emptyFile, "contained \"UTF-8\" text \"\""), new HasDescription("contains \"UTF-8\" text \"0123456789\"") @@ -75,7 +75,7 @@ void testWithPrimitive() throws IOException } assertThat(new ContainsText("0123456789"), new AllOf<>( - new Passes<>(file10Bytes, "contained \"0123456789\""), + new Passes<>(file10Bytes, "contained \"UTF-8\" text \"0123456789\""), new Fails<>(tempDir, new DescribesAs(new MatchesPattern("threw ]+>"))), new Fails<>(emptyFile, "contained \"UTF-8\" text \"\""), new HasDescription("contains \"UTF-8\" text \"0123456789\"") diff --git a/confidence-rxjava3/src/main/java/org/saynotobugs/confidence/rxjava3/rxexpectation/When.java b/confidence-rxjava3/src/main/java/org/saynotobugs/confidence/rxjava3/rxexpectation/When.java index 9b4bfe35..5b817183 100644 --- a/confidence-rxjava3/src/main/java/org/saynotobugs/confidence/rxjava3/rxexpectation/When.java +++ b/confidence-rxjava3/src/main/java/org/saynotobugs/confidence/rxjava3/rxexpectation/When.java @@ -22,9 +22,10 @@ import org.saynotobugs.confidence.Assessment; import org.saynotobugs.confidence.Description; import org.saynotobugs.confidence.Quality; -import org.saynotobugs.confidence.assessment.FailPrepended; +import org.saynotobugs.confidence.assessment.DescriptionUpdated; import org.saynotobugs.confidence.description.Spaced; import org.saynotobugs.confidence.description.Text; +import org.saynotobugs.confidence.description.bifunction.TextAndOriginal; import org.saynotobugs.confidence.rxjava3.RxExpectation; import org.saynotobugs.confidence.rxjava3.RxExpectationComposition; import org.saynotobugs.confidence.rxjava3.RxTestAdapter; @@ -63,8 +64,8 @@ public When(Description triggerDescription, Runnable trigger, RxExpectation d public Assessment assessmentOf(RxTestAdapter candidate) { trigger.run(); - return new FailPrepended( - new Spaced(new Text("when"), triggerDescription), + return new DescriptionUpdated( + new TextAndOriginal<>(new Spaced(new Text("when"), triggerDescription)), new ActionTriggering<>(delegate).quality(testScheduler).assessmentOf(candidate)); } diff --git a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/CompletableThatTest.java b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/CompletableThatTest.java index bb81dffc..96ddf5f2 100644 --- a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/CompletableThatTest.java +++ b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/CompletableThatTest.java @@ -24,7 +24,7 @@ void testComplete() { assertThat(new CompletableThat<>(new Completes<>()), new AllOf<>( - new Passes<>(ignored -> Completable.complete(), "completes exactly once"), + new Passes<>(ignored -> Completable.complete(), "Completable that completes exactly once"), new Fails<>(ignored -> Completable.error(IOException::new), "Completable that had errors [ ]"), new Fails<>(ignored -> Completable.never(), "Completable that completed 0 times"), new HasDescription("Completable that completes exactly once") @@ -37,7 +37,7 @@ void testNever() { assertThat(new CompletableThat<>(new IsAlive<>()), new AllOf<>( - new Passes<>(ignored -> Completable.never(), "is alive"), + new Passes<>(ignored -> Completable.never(), "Completable that is alive"), new Fails<>(ignored -> Completable.error(IOException::new), "Completable that had errors [ ]"), new Fails<>(ignored -> Completable.complete(), "Completable that completes exactly once"), new HasDescription("Completable that is alive") @@ -52,7 +52,7 @@ void testMultiple() new Within<>(Duration.ofMillis(1), new Completes<>())), new AllOf<>( new Passes<>(scheduler -> Completable.complete().delay(1001, TimeUnit.MILLISECONDS, scheduler), - "all of\n" + + "Completable that all of\n" + " 0: after PT1S is alive\n" + " 1: after PT0.001S completes exactly once"), new Fails<>(scheduler -> Completable.error(IOException::new), "Completable that all of\n 0: after PT1S had errors [ ]"), diff --git a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/MaybeThatTest.java b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/MaybeThatTest.java index 9a3eef03..3d1ef585 100644 --- a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/MaybeThatTest.java +++ b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/MaybeThatTest.java @@ -22,7 +22,7 @@ void testNonEmpty() { assertThat(new MaybeThat<>(new Emits<>(new EqualTo<>(123))), new AllOf<>( - new Passes<>(ignored -> Maybe.just(123), "emitted 1 items 123"), + new Passes<>(ignored -> Maybe.just(123), "Maybe that emitted 1 items 123"), new Fails<>(ignored -> Maybe.error(IOException::new), "Maybe that had errors [ ]"), new Fails<>(ignored -> Maybe.empty(), "Maybe that emitted 0 items had 0 elements"), new Fails<>(ignored -> Maybe.just(124), "Maybe that emitted 1 items 124"), @@ -36,7 +36,7 @@ void testEmpty() { assertThat(new MaybeThat<>(new Completes<>()), new AllOf<>( - new Passes<>(ignored -> Maybe.empty(), "completes exactly once"), + new Passes<>(ignored -> Maybe.empty(), "Maybe that completes exactly once"), new Fails<>(ignored -> Maybe.error(IOException::new), "Maybe that had errors [ ]"), new Fails<>(ignored -> Maybe.just(124), "Maybe that emitted [ 124 ]"), new HasDescription("Maybe that completes exactly once") diff --git a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/ObservableThatTest.java b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/ObservableThatTest.java index 076713c5..fde93d5e 100644 --- a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/ObservableThatTest.java +++ b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/ObservableThatTest.java @@ -23,7 +23,7 @@ void testMatch() assertThat(new ObservableThat<>(new Within<>(Duration.ofSeconds(2), new Emits<>(1, 2, 3))), new AllOf<>( new Passes<>(scheduler -> Observable.just(1, 2, 3).delay(2, TimeUnit.SECONDS, scheduler), - "all of\n" + + "Observable that all of\n" + " 0: after PT2S emitted 3 items iterated [\n" + " 0: 1\n" + " 1: 2\n" + diff --git a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/PublisherThatTest.java b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/PublisherThatTest.java index 2e1786fc..27f4d35a 100644 --- a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/PublisherThatTest.java +++ b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/PublisherThatTest.java @@ -24,7 +24,7 @@ void testMatch() assertThat(new PublisherThat<>(new Within<>(Duration.ofSeconds(2), new Emits<>(1, 2, 3))), new AllOf<>( new Passes<>(scheduler -> Flowable.just(1, 2, 3).delay(2, TimeUnit.SECONDS, scheduler), - "all of\n" + + "Publisher that all of\n" + " 0: after PT2S emitted 3 items iterated [\n" + " 0: 1\n" + " 1: 2\n" + @@ -42,7 +42,7 @@ void testMatchInExactly() assertThat(new PublisherThat<>(new InExactly<>(Duration.ofSeconds(2), new Emits<>(1, 2, 3))), new AllOf<>( new Passes<>(scheduler -> Flowable.just(1, 2, 3).delay(2, TimeUnit.SECONDS, scheduler), - "all of\n" + + "Publisher that all of\n" + " 0: in exactly PT2S emitted 3 items iterated [\n" + " 0: 1\n" + " 1: 2\n" + diff --git a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/SingleThatTest.java b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/SingleThatTest.java index 596e63f9..444fc660 100644 --- a/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/SingleThatTest.java +++ b/confidence-rxjava3/src/test/java/org/saynotobugs/confidence/rxjava3/quality/SingleThatTest.java @@ -29,7 +29,7 @@ void testEmits() { assertThat(new SingleThat<>(new Emits<>(new EqualTo<>(123))), new AllOf<>( - new Passes<>(ignored -> Single.just(123), "emitted 1 items 123"), + new Passes<>(ignored -> Single.just(123), "Single that emitted 1 items 123"), new Fails<>(ignored -> Single.error(IOException::new), "Single that had errors [ ]"), new Fails<>(ignored -> Single.just(124), "Single that emitted 1 items 124"), new HasDescription("Single that emits 1 items 123") @@ -41,7 +41,7 @@ void testErrors() { assertThat(new SingleThat<>(new Errors<>(IOException.class)), new AllOf<>( - new Passes<>(ignored -> Single.error(new IOException()), "had errors that iterated [\n" + + new Passes<>(ignored -> Single.error(new IOException()), "Single that had errors that iterated [\n" + " 0: instance of \n" + "]"), new Fails<>(ignored -> Single.error(NoSuchElementException::new), "Single that had errors that iterated [\n 0: instance of \n]"), @@ -57,7 +57,7 @@ void testMultiple() new Within<>(Duration.ofMillis(100), new Emits<>(123))), new AllOf<>( new Passes<>((Function>) scheduler -> Single.just(123).delay(200, TimeUnit.MILLISECONDS, scheduler), - "all of\n" + + "Single that all of\n" + " 0: after PT0.1S emitted nothing\n" + " 1: after PT0.1S emitted 1 items 123"), new Fails<>((Function>) scheduler -> Single.error(NoSuchElementException::new),