@Test
public void testDeclaration() {

    InternalKnowledgePackage pkg = new KnowledgePackageImpl( "org.store" );
    final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
                                                            0,
                                                            String.class );
    final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
                                                             1,
                                                             Integer.class );
    final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
    final FactTemplate cheese = new FactTemplateImpl( pkg,
                                                      "Cheese",
                                                      fields );
    final InternalReadAccessor extractName = new FactTemplateFieldExtractor( cheese,
                                                                  0 );
    final Pattern pattern = new Pattern( 0,
                                      new FactTemplateObjectType( cheese ) );
    final Declaration declaration = new Declaration( "typeOfCheese",
                                                     extractName,
                                                     pattern );
    final Fact brie = cheese.createFact( 12 );
    brie.setFieldValue( "name",
                        "brie" );
    brie.setFieldValue( "price",
                        new Integer( 55 ) );
    // Check we can extract Declarations correctly 
    assertEquals( "brie",
                  declaration.getValue( null, brie ) );
}