@Test(expected = IllegalArgumentException.class)
 public void testRegisterAllIdentifiedObjectSchemasNestedDuplicate() {
   List<ObjectSchema> list = new ArrayList<ObjectSchema>();
   // Create a duplicate
   ObjectSchema root1 = ObjectSchema.createNewWithId("rootOne");
   list.add(root1);
   ObjectSchema root2 = ObjectSchema.createNewWithId("rootTwo");
   list.add(root2);
   // Add a child to each with a duplicate name
   root1.setItems(ObjectSchema.createNewWithId("child"));
   // Add a child to each with a duplicate name
   root2.setItems(ObjectSchema.createNewWithId("child"));
   // This should fail due to the duplicate
   PojoGeneratorDriver.registerAllIdentifiedObjectSchemas(list);
 }
  @Test
  public void testFindAndReplaceAllReferencesSchemasFull() {
    String referenceId = new String("rootOne");
    ObjectSchema referenced = ObjectSchema.createNewWithId(referenceId);
    HashMap<String, ObjectSchema> registry = new HashMap<String, ObjectSchema>();
    // Add the referenced schema to the register.
    registry.put(referenceId, referenced);
    // Create a third self
    ObjectSchema self = ObjectSchema.createNewWithId(new String("self"));
    ObjectSchema refToSelf = new ObjectSchema();
    refToSelf.setRef(new String(ObjectSchema.SELF_REFERENCE));

    ObjectSchema referenceToOther = new ObjectSchema();
    referenceToOther.setRef(referenceId);

    // Add references in all places
    self.putProperty("one", referenceToOther);
    self.putAdditionalProperty("two", referenceToOther);
    self.setItems(refToSelf);
    self.setAdditionalItems(refToSelf);
    self.setImplements(new ObjectSchema[] {referenceToOther});

    // find and replace
    PojoGeneratorDriver.findAndReplaceAllReferencesSchemas(registry, self);
    // Make sure there are no references
    Iterator<ObjectSchema> it = self.getSubSchemaIterator();
    while (it.hasNext()) {
      ObjectSchema toTest = it.next();
      assertTrue(toTest.getRef() == null);
    }
  }
 @Test
 public void testRecursivlyCreateAllTypesArrayNull() throws ClassNotFoundException {
   schema.setType(TYPE.ARRAY);
   ObjectSchema arrayType = new ObjectSchema();
   arrayType.setType(TYPE.NULL);
   schema.setItems(arrayType);
   JCodeModel codeModel = new JCodeModel();
   JType type = driver.createOrGetType(codeModel, schema);
   assertNotNull(type);
   assertEquals(List.class.getName() + "<" + Object.class.getName() + ">", type.fullName());
 }
 @Test
 public void testRegisterAllIdentifiedObjectSchemasNested() {
   List<ObjectSchema> list = new ArrayList<ObjectSchema>();
   // Create a duplicate
   ObjectSchema root1 = ObjectSchema.createNewWithId("rootOne");
   list.add(root1);
   ObjectSchema root2 = ObjectSchema.createNewWithId("rootTwo");
   list.add(root2);
   // Add a child to each with a unique name
   root1.setItems(ObjectSchema.createNewWithId("child1"));
   // Add a child to each with a unique name
   root2.setItems(ObjectSchema.createNewWithId("child2"));
   // This should not fail this time.
   Map<String, ObjectSchema> map = PojoGeneratorDriver.registerAllIdentifiedObjectSchemas(list);
   assertNotNull(map);
   assertEquals(4, map.size());
   assertEquals(root1, map.get(new String("rootOne")));
   assertEquals(root2, map.get(new String("rootTwo")));
   assertNotNull(map.get(new String("child1")));
   assertNotNull(map.get(new String("child2")));
 }
 @Test
 public void testRecursivlyCreateAllTypesArrayAnySet() throws ClassNotFoundException {
   schema.setType(TYPE.ARRAY);
   // set it to be unique to get a set
   schema.setUniqueItems(true);
   ObjectSchema arrayType = new ObjectSchema();
   arrayType.setType(TYPE.ANY);
   schema.setItems(arrayType);
   JCodeModel codeModel = new JCodeModel();
   JType type = driver.createOrGetType(codeModel, schema);
   assertNotNull(type);
   assertEquals(Set.class.getName() + "<" + Object.class.getName() + ">", type.fullName());
 }