@Test
  public void testEnititySet() throws Exception {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf =
        new MetadataFactory(
            "vdb",
            1,
            "trippin",
            SystemMetadata.getInstance().getRuntimeTypeMap(),
            new Properties(),
            null);

    ArrayList<CsdlProperty> properties = new ArrayList<CsdlProperty>();
    properties.add(
        createProperty("name", EdmPrimitiveTypeKind.String).setMaxLength(25).setNullable(false));
    properties.add(createProperty("dob", EdmPrimitiveTypeKind.DateTimeOffset).setNullable(true));
    properties.add(createProperty("ssn", EdmPrimitiveTypeKind.Int64).setNullable(false));

    CsdlEntityType entityType = new CsdlEntityType();
    entityType.setName("Person");
    entityType.setProperties(properties);
    entityType.setKey(Arrays.asList(new CsdlPropertyRef().setName("ssn")));

    CsdlEntitySet es = createES("Persons", "namespace.Person");

    XMLMetadata metadata = buildXmlMetadata(es, entityType);

    processor.getMetadata(mf, metadata);

    assertNotNull(mf.getSchema().getTable("Persons"));

    Table person = mf.getSchema().getTable("Persons");
    assertEquals(3, person.getColumns().size());

    assertNotNull(person.getColumnByName("name"));
    assertNotNull(person.getColumnByName("dob"));
    assertNotNull(person.getColumnByName("ssn"));

    Column name = person.getColumnByName("name");
    Column dob = person.getColumnByName("dob");
    Column ssn = person.getColumnByName("ssn");

    assertEquals("string", name.getDatatype().getRuntimeTypeName());
    assertEquals("timestamp", dob.getDatatype().getRuntimeTypeName());
    assertEquals("long", ssn.getDatatype().getRuntimeTypeName());

    assertTrue(name.getNullType() == NullType.No_Nulls);
    assertTrue(dob.getNullType() == NullType.Nullable);
    assertTrue(ssn.getNullType() == NullType.No_Nulls);

    assertEquals(25, name.getLength());

    assertNotNull(person.getPrimaryKey());

    assertEquals(1, person.getPrimaryKey().getColumns().size());
    assertEquals("ssn", person.getPrimaryKey().getColumns().get(0).getName());

    assertTrue(person.getForeignKeys().isEmpty());
  }
  private CsdlEntityType buildBusinessEntity(CsdlComplexType address) {
    ArrayList<CsdlProperty> properties = new ArrayList<CsdlProperty>();
    properties.add(createProperty("name", EdmPrimitiveTypeKind.String).setMaxLength(25));
    properties.add(new CsdlProperty().setName("address").setType(address.getName()));

    CsdlEntityType entityType = new CsdlEntityType();
    entityType.setName("Business");
    entityType.setProperties(properties);
    entityType.setKey(Arrays.asList(new CsdlPropertyRef().setName("name")));
    return entityType;
  }
  static CsdlEntityType entityType(String name) {
    ArrayList<CsdlProperty> properties = new ArrayList<CsdlProperty>();
    properties.add(createProperty("e1", EdmPrimitiveTypeKind.Int32));
    properties.add(createProperty("e2", EdmPrimitiveTypeKind.String).setNullable(false));

    CsdlEntityType entityType = new CsdlEntityType();
    entityType.setName(name);
    entityType.setProperties(properties);
    entityType.setKey(Arrays.asList(new CsdlPropertyRef().setName("e1")));
    return entityType;
  }
  static CsdlEntityType buildPersonEntity(CsdlComplexType address) {
    ArrayList<CsdlProperty> properties = new ArrayList<CsdlProperty>();
    properties.add(createProperty("name", EdmPrimitiveTypeKind.String).setMaxLength(25));
    properties.add(createProperty("ssn", EdmPrimitiveTypeKind.Int64).setNullable(false));
    properties.add(new CsdlProperty().setName("address").setType(address.getName()));
    properties.add(new CsdlProperty().setName("secondaddress").setType(address.getName()));

    CsdlEntityType entityType = new CsdlEntityType();
    entityType.setName("Person");
    entityType.setProperties(properties);
    entityType.setKey(Arrays.asList(new CsdlPropertyRef().setName("ssn")));
    return entityType;
  }