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());
    }
}

@@ -52,22 +52,22 @@
 filters.
-Filt
+Inv
 er
+t
 ;%0Aimport
@@ -96,39 +96,21 @@
 ers.
-Invert;%0Aimport org.junit.Ass
+PatternFilt
 er
-t
 ;%0Aim
@@ -134,100 +134,56 @@
 st;%0A
+%0A
 import 
-org.junit.runner.RunWith;%0Aimport org.springframework.test.context.junit4.SpringRunner
+static org.assertj.core.api.Assertions.*
 ;%0A%0A/
@@ -472,41 +472,164 @@
     
-A
+a
 ssert
-.assertNotNull(censusConfig
+That(censusConfig).isNotNull();%0A        assertThat(censusConfig.getSubjects()).isNotNull();%0A        assertThat(censusConfig.getSubjects()).isNotEmpty(
 );%0A 
@@ -635,36 +635,90 @@
         
-A
+a
 ssert
-.assertNotNull
+That(censusConfig.getSubjects().size()).isOne();%0A%0A        assertThat
 (censusC
@@ -736,28 +736,46 @@
 bjects()
+.get(0)).isNotNull(
 );%0A
-%0A
         
 Assert.a
@@ -770,74 +770,167 @@
     
-A
+a
 ssert
-.assertFalse(censusConfig.getSubjects().isEmpty()
+That(censusConfig.getSubjects().get(0).getId()).isEqualTo(%221%22);%0A        assertThat(censusConfig.getSubjects().get(0).getName()).isEqualTo(%22a%22
 );%0A
+%0A
         
 Asse
@@ -929,26 +929,98 @@
     
-A
+a
 ssert
-.assertFalse
+That(censusConfig.getSubjects().get(0).getFilters()).isNotNull();%0A        assertThat
 (cen
@@ -1066,21 +1066,23 @@
 rs()
+)
 .is
+Not
 Empty()
-);%0A
+;
 %0A   
@@ -1090,24 +1090,19 @@
     
-Filter filter = 
+assertThat(
 cens
@@ -1148,24 +1148,34 @@
 s().
-get(0
+size()).isOne(
 );%0A
+%0A
         
 Asse
@@ -1174,50 +1174,99 @@
     
-A
+a
 ssert
-.assertTrue(filter i
+That(censusConfig.getSubjects().get(0).getFilters().get(0)).isI
 nstance
-of 
+Of(
 Invert
+.class
 );%0A%0A
@@ -1298,22 +1298,69 @@
 Invert) 
-filter
+censusConfig.getSubjects().get(0).getFilters().get(0)
 ;%0A      
@@ -1365,48 +1365,125 @@
     
-A
+a
 ssert
-.assertNotNull(invert.getWrapped()
+That(invert.getWrapped()).isNotNull();%0A        assertThat(invert.getWrapped()).isInstanceOf(PatternFilter.class
 );%0A 

Rewrite with assertj