dimanche 13 octobre 2019

What assertion test case can I write for this program?

I have written 1 assert test case for my Java program. I need to write one more test case for my program to pass Sonarqube test. I am not sure what other assert test case I can write to pass this sonarqube test.

Here is my code for DefaultAllFundsPerformanceTableConsumer.java

package com.trp.gis.gdx.services.product.processor.table.allfunds.localized;

import com.trp.gis.gdx.services.product.common.localization.LocalizedProductMessage;
import com.trp.gis.gdx.services.product.common.model.table.PerformanceTableView;
import java.util.function.Consumer;

@Component("defaultAllFundsPerformanceTableConsumer")
public class DefaultAllFundsPerformanceTableConsumer implements Consumer<LocalizedProductMessage> {
    private static final Logger LOG = LoggerFactory.getLogger(DefaultAllFundsPerformanceTableConsumer.class);

    private final OptimisticLockFlowManager<PerformanceTableView> flowManager;
    private final SiteMapProvider siteMapProvider;

    public DefaultAllFundsPerformanceTableConsumer(
            final OptimisticLockFlowManager<PerformanceTableView> flowManager,
            final SiteMapProvider siteMapProvider) {
        this.flowManager = flowManager;
        this.siteMapProvider = siteMapProvider;
    }


    @Override
    public void accept(LocalizedProductMessage localizedProductMessage) {
        LOG.info("ignore "+localizedProductMessage.getKey());

    }
}

Here is the test case I wrote for this class

package com.trp.gis.gdx.services.product.processor.table.allfunds.localized;

import com.trp.gis.gdx.services.product.common.enums.AssetClass;
import com.trp.gis.gdx.services.product.common.enums.Audience;
import com.trp.gis.gdx.services.product.common.enums.Country;
import com.trp.gis.gdx.services.product.common.enums.Language;
import com.trp.gis.gdx.services.product.common.enums.Vehicle;
import com.trp.gis.gdx.services.product.common.localization.LocalizedProductMessage;
import com.trp.gis.gdx.services.product.common.model.table.PerformanceTableView;
import com.trp.gis.gdx.services.product.processor.common.service.SiteMapProvider;
import com.trp.gis.gdx.services.product.processor.common.storage.OptimisticLockFlowManager;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertTrue;

public class DefaultAllFundsPerformanceTableConsumerTest
{
    LocalizedProductMessage                 message;
    DefaultAllFundsPerformanceTableConsumer consumer;

    private OptimisticLockFlowManager<PerformanceTableView> flowManager;
    private SiteMapProvider siteMapProvider;

    @Before
    public void setUp()
    {
        message = LocalizedProductMessage.builder()
                .ingestedData("Test")
                .key("1")
                .audience(Audience.INSTITUTIONAL)
                .vehicleType(Vehicle.US_MUTUAL_FUND)
                .country(Country.UNITED_STATES)
                .language(Language.ENGLISH)
                .assetClass(AssetClass.EQUITY)
                .build();
        consumer =
                new DefaultAllFundsPerformanceTableConsumer(flowManager,
                        siteMapProvider);
    }

    @Test
    public void accept()
    {
        consumer.accept(message);
        assertTrue("Pass", true);
    }
}

I need some guidance to write one more assert test case to pass sonarqube.

Aucun commentaire:

Enregistrer un commentaire