// Create the factory
PolicyValueFactory factory = new DefaultPolicyValueFactory(accessor);
// Call the creation method on the factory
PolicyValue value = factory.createPolicyValue(device, "policyname");
// Check test outcome
assertNotNull("Policy value should exist", value);
assertTrue("Based on test setup expected a StructurePolicyValue",
value instanceof StructurePolicyValue);
StructurePolicyValue structureValue = (StructurePolicyValue) value;
Map fields = structureValue.getFieldValuesAsMap();
assertNotNull("Should be a map of values", fields);
assertEquals("Should be 4 items in the map", fields.size(), 4);
PolicyValue value1 = (PolicyValue) fields.get("field1");
assertNotNull("field1 should not be null", value1);
PolicyValue value2 = (PolicyValue) fields.get("field2");
assertNotNull("field2 should not be null", value2);
PolicyValue value3 = (PolicyValue) fields.get("field3");
assertNotNull("field3 should not be null", value3);
PolicyValue value4 = (PolicyValue) fields.get("field4");
assertNull("field4 should be null", value4);
assertTrue("field1 should be text value",
value1 instanceof TextPolicyValue);
assertTrue("field2 should be boolean value",