package lb.census.config;

import lb.census.record.filters.Filter;
import lb.census.record.filters.Invert;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * Created by philippe on 27/06/2017.
 */
public class CensusconfigTest {

    @Test
    public void readConfig() {
        CensusConfigFactory factory = new CensusConfigFactory();
        CensusConfig censusConfig = factory.loadFrom(getClass().getResource("/config.xml"));

        Assert.assertNotNull(censusConfig);
        Assert.assertNotNull(censusConfig.getSubjects());

        Assert.assertFalse(censusConfig.getSubjects().isEmpty());
        Assert.assertFalse(censusConfig.getSubjects().get(0).getFilters().isEmpty());

        Filter filter = censusConfig.getSubjects().get(0).getFilters().get(0);
        Assert.assertTrue(filter instanceof Invert);

        Invert invert = (Invert) filter;
        Assert.assertNotNull(invert.getWrapped());
    }
}

package lb.census.config;

import lb.census.record.filters.Invert;
import lb.census.record.filters.PatternFilter;
import org.junit.Test;

import static org.assertj.core.api.Assertions.*;

/**
 * Created by philippe on 27/06/2017.
 */
public class CensusconfigTest {

    @Test
    public void readConfig() {
        CensusConfigFactory factory = new CensusConfigFactory();
        CensusConfig censusConfig = factory.loadFrom(getClass().getResource("/config.xml"));

        assertThat(censusConfig).isNotNull();
        assertThat(censusConfig.getSubjects()).isNotNull();
        assertThat(censusConfig.getSubjects()).isNotEmpty();
        assertThat(censusConfig.getSubjects().size()).isOne();

        assertThat(censusConfig.getSubjects().get(0)).isNotNull();
        assertThat(censusConfig.getSubjects().get(0).getId()).isEqualTo("1");
        assertThat(censusConfig.getSubjects().get(0).getName()).isEqualTo("a");

        assertThat(censusConfig.getSubjects().get(0).getFilters()).isNotNull();
        assertThat(censusConfig.getSubjects().get(0).getFilters()).isNotEmpty();
        assertThat(censusConfig.getSubjects().get(0).getFilters().size()).isOne();

        assertThat(censusConfig.getSubjects().get(0).getFilters().get(0)).isInstanceOf(Invert.class);

        Invert invert = (Invert) censusConfig.getSubjects().get(0).getFilters().get(0);
        assertThat(invert.getWrapped()).isNotNull();
        assertThat(invert.getWrapped()).isInstanceOf(PatternFilter.class);
    }
}

Rewrite with assertj