### Question:
Instance { public Attribute getAttr(String fieldName) { return attributes.get(fieldName); } Instance(); double getWeight(); void setWeight(double w); void setAttr(String name, Object value); Attribute getAttr(String fieldName); Object getAttrValue(String fieldName); int hashCode(); String toString();  }### Answer:
@Test public void testInstanceCreationAndReadAccessor() { Schema schema = Schema.createSchemaStructure(Car.class, Learner.DataType.STRUCTURED); InstanceFactory instFactory = new InstanceFactory(schema); Instance m1 = instFactory.createInstance(new Car( "m1",2, "s", "p", "low")); Instance m2 = instFactory.createInstance(new Car( "m2",2, "s", "d", "medium")); Instance m3 = instFactory.createInstance(new Car( "m3",2, "s", "e", "high")); assertEquals( "m1", m1.getAttr("org.drools.learner.Car@model").getValue() ); assertEquals( "s", m2.getAttr("org.drools.learner.Car@size").getValue() ); assertEquals( "e", m3.getAttr("org.drools.learner.Car@fuel").getValue() ); }