Search in sources :

Example 86 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project gdsc by aherbert.

the class FindFociTest method isEqual.

private static void isEqual(boolean legacy, FindFociResults r1, FindFociResults r2, int set, boolean negativeValues, boolean nonContiguous) {
    final String setName = String.format("Set %d (%b)", set, nonContiguous);
    final ImagePlus imp1 = r1.mask;
    final ImagePlus imp2 = r2.mask;
    Assertions.assertEquals(imp1 != null, imp2 != null, setName + " Mask");
    if (imp1 != null) {
    // Assertions.assertArrayEquals(set + " Mask values", (float[])
    // (imp1.getProcessor().convertToFloat().getPixels()),
    // (float[]) (imp2.getProcessor().convertToFloat().getPixels()), 0);
    }
    final List<FindFociResult> results1 = r1.results;
    final List<FindFociResult> results2 = r2.results;
    // logger.log(TestLevel.TEST_INFO, Lambdas.getSupplier("N1=%d, N2=%d", results1.size(),
    // results2.size());
    Assertions.assertEquals(results1.size(), results2.size(), setName + " Results Size");
    int counter = 0;
    final int offset = (negativeValues) ? OFFSET : 0;
    final DoubleDoubleBiPredicate predictate = Predicates.doublesAreClose(1e-9, 1e-16);
    try {
        for (int i = 0; i < results1.size(); i++) {
            counter = i;
            final FindFociResult o1 = results1.get(i);
            final FindFociResult o2 = results2.get(i);
            // logger.log(TestLevel.TEST_INFO, Lambdas.getSupplier(
            // "[%d] %d,%d %f (%d) %d vs %d,%d %f (%d) %d", i,
            // o1.x, o1.y, o1.maxValue, o1.count, o1.saddleNeighbourId,
            // o2.x, o2.y, o2.maxValue, o2.count, o2.saddleNeighbourId);
            Assertions.assertEquals(o1.x, o2.x, "X");
            Assertions.assertEquals(o1.y, o2.y, "Y");
            Assertions.assertEquals(o1.z, o2.z, "Z");
            Assertions.assertEquals(o1.id, o2.id, "ID");
            Assertions.assertEquals(o1.count, o2.count, "Count");
            Assertions.assertEquals(o1.saddleNeighbourId, o2.saddleNeighbourId, "Saddle ID");
            Assertions.assertEquals(o1.countAboveSaddle, o2.countAboveSaddle, "Count >Saddle");
            // Single/Summed values can be cast to long as they should be 16-bit integers
            Assertions.assertEquals((long) o1.maxValue, (long) o2.maxValue + offset, "Max");
            if (o2.highestSaddleValue != Float.NEGATIVE_INFINITY && o2.highestSaddleValue != 0) {
                Assertions.assertEquals((long) o1.highestSaddleValue, (long) o2.highestSaddleValue + offset, "Saddle value");
            }
            if (legacy) {
                // Cast to integer as this is the result format of the legacy FindFoci code
                Assertions.assertEquals((long) o1.averageIntensity, (long) o2.averageIntensity + offset, "Av Intensity");
                Assertions.assertEquals((long) o1.averageIntensityAboveBackground, (long) o2.averageIntensityAboveBackground, "Av Intensity >background");
            } else {
                // Averages cannot be cast and are compared as floating-point values
                TestAssertions.assertTest(o1.averageIntensity, o2.averageIntensity + offset, predictate, "Av Intensity");
                TestAssertions.assertTest(o1.averageIntensityAboveBackground, o2.averageIntensityAboveBackground, predictate, "Av Intensity >background");
            }
            if (negativeValues) {
                continue;
            }
            Assertions.assertEquals((long) o1.totalIntensity, (long) o2.totalIntensity, "Intensity");
            Assertions.assertEquals((long) o1.totalIntensityAboveBackground, (long) o2.totalIntensityAboveBackground, "Intensity >background");
            Assertions.assertEquals((long) o1.intensityAboveSaddle, (long) o2.intensityAboveSaddle, "Intensity > Saddle");
        }
    } catch (final AssertionFailedError ex) {
        AssertionErrors.prependMessage(ex, FormatSupplier.getSupplier("%s [%d]", setName, counter));
    }
}
Also used : DoubleDoubleBiPredicate(uk.ac.sussex.gdsc.test.api.function.DoubleDoubleBiPredicate) AssertionFailedError(org.opentest4j.AssertionFailedError) ImagePlus(ij.ImagePlus)

Example 87 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.

the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_fail_with_message_having_args.

@Test
void should_fail_with_message_having_args() {
    // WHEN
    AssertionFailedError afe = expectAssertionFailedError(() -> assertion.failWithActualExpectedAndMessage(actual, expected, "fail %d %s %%s", 5, "times"));
    // THEN
    then(afe).hasMessage("fail 5 times %s");
    then(afe.getActual().getEphemeralValue()).isSameAs(actual);
    then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Example 88 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.

the class AbstractAssert_failWithActualExpectedAndMessage_Test method expectAssertionFailedError.

static AssertionFailedError expectAssertionFailedError(ThrowingCallable shouldRaiseAssertionError) {
    AssertionFailedError error = catchThrowableOfType(shouldRaiseAssertionError, AssertionFailedError.class);
    assertThat(error).as("The code under test should have raised an AssertionFailedError").isNotNull();
    return error;
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 89 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.

the class AbstractAssert_failureWithActualExpected_Test method should_create_failure_with_simple_message.

@Test
void should_create_failure_with_simple_message() {
    // WHEN
    AssertionFailedError afe = assertion.failureWithActualExpected(actual, expected, "fail");
    // THEN
    then(afe).hasMessage("fail");
    then(afe.getActual().getEphemeralValue()).isSameAs(actual);
    then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Example 90 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.

the class AbstractAssert_failureWithActualExpected_Test method should_keep_specific_error_message_and_description_set_by_user.

@Test
void should_keep_specific_error_message_and_description_set_by_user() {
    // WHEN
    AssertionFailedError afe = assertion.as("test context").overridingErrorMessage("my %d errors %s", 5, "!").failureWithActualExpected(actual, expected, "%d %s", 5, "time");
    // THEN
    then(afe).hasMessage("[test context] my 5 errors !");
    then(afe.getActual().getEphemeralValue()).isSameAs(actual);
    then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Aggregations

AssertionFailedError (org.opentest4j.AssertionFailedError)153 Test (org.junit.jupiter.api.Test)72 AssertionTestUtils.expectAssertionFailedError (org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)12 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)8 IOException (java.io.IOException)8 URI (java.net.URI)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)8 Collectors (java.util.stream.Collectors)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 ThrowingCallable (org.assertj.core.api.ThrowableAssert.ThrowingCallable)4 GeneCentricEntry (org.uniprot.core.genecentric.GeneCentricEntry)4 GeneCentricDocument (org.uniprot.store.search.document.genecentric.GeneCentricDocument)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)3 Search (io.zulia.client.command.builder.Search)3 SearchResult (io.zulia.client.result.SearchResult)3 ExecutionException (java.util.concurrent.ExecutionException)3 Assertions (org.junit.jupiter.api.Assertions)3