@Test
public void defaultClass()
{

    final CategoryOption co1 = new CategoryOption();
    co1.setUid( "abc1" );
    final CategoryOption co2 = new CategoryOption();
    co2.setUid( "abc2" );
    co2.setName( "default" );
    final CategoryOption co3 = new CategoryOption();
    co3.setUid( "abc3" );
    final Category category = new Category();
    category.setUid( "def1" );
    category.getCategoryOptions().add( co1 );
    category.getCategoryOptions().add( co2 );
    category.getCategoryOptions().add( co3 );
    final FieldFilterParams params = new FieldFilterParams( Collections.singletonList( category ), Arrays.asList( "id", "categoryOptions" ) );
    params.setDefaults( Defaults.EXCLUDE );
    final ComplexNode node = service.toComplexNode( params );
    Assert.assertEquals( "category", node.getName() );
    Assert.assertTrue( getNamedNode( node.getUnorderedChildren(), "id" ) instanceof SimpleNode );
    Assert.assertEquals( "def1", ( (SimpleNode) getNamedNode( node.getUnorderedChildren(), "id" ) ).getValue() );
    Assert.assertTrue( getNamedNode( node.getUnorderedChildren(), "categoryOptions" ) instanceof CollectionNode );
    final CollectionNode collectionNode = (CollectionNode) getNamedNode( node.getUnorderedChildren(), "categoryOptions" );
    Assert.assertEquals( 2, collectionNode.getUnorderedChildren().size() );
    final List<String> coIds = new ArrayList<>();
    Assert.assertTrue( collectionNode.getUnorderedChildren().get( 0 ) instanceof ComplexNode );
    ComplexNode complexNode = (ComplexNode) collectionNode.getUnorderedChildren().get( 0 );
    Assert.assertEquals( "categoryOption", complexNode.getName() );
    Assert.assertEquals( 1, complexNode.getUnorderedChildren().size() );
    Assert.assertTrue( complexNode.getUnorderedChildren().get( 0 ) instanceof SimpleNode );
    SimpleNode simpleNode = (SimpleNode) complexNode.getUnorderedChildren().get( 0 );
    Assert.assertEquals( "id", simpleNode.getName() );
    coIds.add( String.valueOf( simpleNode.getValue() ) );
    Assert.assertTrue( collectionNode.getUnorderedChildren().get( 1 ) instanceof ComplexNode );
    complexNode = (ComplexNode) collectionNode.getUnorderedChildren().get( 1 );
    Assert.assertEquals( "categoryOption", complexNode.getName() );
    Assert.assertEquals( 1, complexNode.getUnorderedChildren().size() );
    Assert.assertTrue( complexNode.getUnorderedChildren().get( 0 ) instanceof SimpleNode );
    simpleNode = (SimpleNode) complexNode.getUnorderedChildren().get( 0 );
    Assert.assertEquals( "id", simpleNode.getName() );
    coIds.add( String.valueOf( simpleNode.getValue() ) );
    Assert.assertThat( coIds, Matchers.containsInAnyOrder( "abc1", "abc3" ) );
}