java:S2699 Add at least one assertion to this test case using AssertableApplicationContext

When I use spring AssertableApplicationContext, I get s2699 but the assertions are done using assertThat which is not recognized as assertion. This is a false positive and the scanner should take into account assertThat
Import

import static org.assertj.core.api.Assertions.assertThat;
import java.util.Properties;
import org.apache.kafka.streams.StreamsBuilder;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;

The code snippet is

    @Test
    final void testServiceConfig() {
**==> Add at least one assertion to this test case.**

        ContextConsumer<AssertableApplicationContext> assertConfig = new AssertConfig();
        contextRunner //
                .withPropertyValues("kafka.bootstrap.servers=localhost:3333", //
                        "ems.maintenance.service.replication.factor=1")
                .run(assertConfig);
    }
    class AssertConfig implements ContextConsumer<AssertableApplicationContext> {
        @Override
        public void accept(AssertableApplicationContext context) throws Throwable {
            assertThat(context).getBean("streamsConfig").isInstanceOf(Properties.class);
            assertThat(context).getBean("kStreamBuilder").isInstanceOf(StreamsBuilder.class);
        }
    }

Please let me know if it could be fixed.
Thank a lot in advance

Hi Francois,

Thank you for the report!

I believe the problem is that we do not track assertions that are invoked via the AssertableApplicationContext. We would like to fix this, so I have created a ticket (SONARJAVA-5480) to track this issue.

Thanks a lot, it would be really great because we use it for every Spring configuration :slight_smile: