@Test
public void testImportIndsFromJson() throws Exception {

    DefaultMetadataStore metadataStore = new DefaultMetadataStore();
    Schema schema = metadataStore.addSchema("SG", "", new DefaultLocation());
    Table sgBiodatabase = schema.addTable(metadataStore, "SG_BIODATABASE.csv", "", new DefaultLocation());
    for (int i = 0; i < 8; i++) {
        sgBiodatabase.addColumn(
                metadataStore,
                String.format("[%d]", i), // MDMS style
                "",
                i
        );
    }
    Table sgBioentry = schema.addTable(metadataStore, "SG_BIOENTRY.csv", "", new DefaultLocation());
    for (int i = 0; i < 8; i++) {
        sgBioentry.addColumn(
                metadataStore,
                String.format("[%d]", i), // MDMS style
                "",
                i
        );
    }
    Table sgTerm = schema.addTable(metadataStore, "SG_TERM.csv", "", new DefaultLocation());
    for (int i = 0; i < 6; i++) {
        sgTerm.addColumn(
                metadataStore,
                String.format("[%d]", i), // MDMS style
                "",
                i
        );
    }
    Table sgOntology = schema.addTable(metadataStore, "SG_ONTOLOGY.csv", "", new DefaultLocation());
    for (int i = 0; i < 1; i++) {
        sgOntology.addColumn(
                metadataStore,
                String.format("[%d]", i), // MDMS style
                "",
                i
        );
    }
    File inputFile = new File(Thread.currentThread().getContextClassLoader().getResource("metanome-inds.json").toURI());
    MetanomeDependencyImportApp.fromParameters(
            metadataStore,
            inputFile.getAbsolutePath(),
            ".+",
            "json",
            "IND",
            "SG",
            "SG",
            null
    );
    Collection<ConstraintCollection<InclusionDependency>> constraintCollections =
            metadataStore.getConstraintCollectionByConstraintTypeAndScope(
                    InclusionDependency.class, metadataStore.getTargetByName("SG")
            );
    Assert.assertEquals(1, constraintCollections.size());
    ConstraintCollection<InclusionDependency> constraintCollection = constraintCollections.iterator().next();
    Assert.assertEquals(2, constraintCollection.getConstraints().size());
    Set<InclusionDependency> discoveredInds = new HashSet<>(constraintCollection.getConstraints());
    Set<InclusionDependency> expectedInds = new HashSet<>();
    expectedInds.add(new InclusionDependency(
            ReferenceUtils.toIntArray(new Column[]{
                    sgBiodatabase.getColumnByName("[0]"),
                    sgBiodatabase.getColumnByName("[2]"),
                    sgBiodatabase.getColumnByName("[3]"),
                    sgBiodatabase.getColumnByName("[4]"),
                    sgBiodatabase.getColumnByName("[5]")
            }),
            ReferenceUtils.toIntArray(new Column[]{
                    sgBioentry.getColumnByName("[7]"),
                    sgBioentry.getColumnByName("[0]"),
                    sgBioentry.getColumnByName("[1]"),
                    sgBioentry.getColumnByName("[2]"),
                    sgBioentry.getColumnByName("[3]")
            })
    ));
    expectedInds.add(new InclusionDependency(
            ReferenceUtils.toIntArray(new Column[]{sgTerm.getColumnByName("[5]")}),
            ReferenceUtils.toIntArray(new Column[]{sgOntology.getColumnByName("[0]")})
    ));
    Assert.assertEquals(expectedInds, discoveredInds);
}