Search in sources :

Example 1 with MetaGroup

use of ml.shifu.shifu.container.meta.MetaGroup in project shifu by ShifuML.

the class ItemMetaGroupTest method testOutput.

@Test
public void testOutput() throws JsonGenerationException, JsonMappingException, IOException {
    List<MetaGroup> groupList = new ArrayList<MetaGroup>();
    MetaGroup itemGrpA = new MetaGroup();
    itemGrpA.setGroup("basic");
    List<MetaItem> metaList = new ArrayList<MetaItem>();
    MetaItem meta = new MetaItem();
    meta.setName("author");
    meta.setType("text");
    meta.setDirective("input");
    meta.setMinLength(1);
    metaList.add(meta);
    itemGrpA.setMetaList(metaList);
    groupList.add(itemGrpA);
    MetaGroup itemGrpB = new MetaGroup();
    itemGrpB.setGroup("sourceData");
    List<MetaItem> metaListB = new ArrayList<MetaItem>();
    MetaItem metaB = new MetaItem();
    metaB.setName("dataPath");
    metaB.setType("text");
    metaB.setDirective("input");
    metaB.setMinLength(1);
    metaListB.add(metaB);
    itemGrpB.setMetaList(metaListB);
    groupList.add(itemGrpB);
    File file = new File("test-meta.json");
    jsonMapper.writerWithDefaultPrettyPrinter().writeValue(file, groupList);
    MetaGroup[] ga = jsonMapper.readValue(file, MetaGroup[].class);
    Assert.assertEquals(groupList.size(), ga.length);
    file.deleteOnExit();
}
Also used : MetaItem(ml.shifu.shifu.container.meta.MetaItem) ArrayList(java.util.ArrayList) MetaGroup(ml.shifu.shifu.container.meta.MetaGroup) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with MetaGroup

use of ml.shifu.shifu.container.meta.MetaGroup in project shifu by ShifuML.

the class ItemMetaGroupTest method testReadMetaGroup.

@Test
public void testReadMetaGroup() throws JsonParseException, JsonMappingException, IOException {
    File file = new File("src/main/resources/store/ModelConfigMeta.json");
    MetaGroup[] ga = jsonMapper.readValue(file, MetaGroup[].class);
    Assert.assertEquals(7, ga.length);
}
Also used : MetaGroup(ml.shifu.shifu.container.meta.MetaGroup) File(java.io.File) Test(org.testng.annotations.Test)

Example 3 with MetaGroup

use of ml.shifu.shifu.container.meta.MetaGroup in project shifu by ShifuML.

the class ItemMetaGroupTest method testCloneMeta.

@Test
public void testCloneMeta() {
    MetaGroup group = new MetaGroup();
    MetaGroup cloneObj = group.clone();
    Assert.assertNull(cloneObj.getGroup());
    group.setGroup("testGroup");
    List<MetaItem> itemList = new ArrayList<MetaItem>();
    MetaItem meta = new MetaItem();
    itemList.add(meta);
    itemList.add(meta.clone());
    itemList.add(meta.clone());
    group.setMetaList(itemList);
    cloneObj = group.clone();
    Assert.assertEquals("testGroup", cloneObj.getGroup());
    Assert.assertEquals(3, cloneObj.getMetaList().size());
}
Also used : MetaItem(ml.shifu.shifu.container.meta.MetaItem) ArrayList(java.util.ArrayList) MetaGroup(ml.shifu.shifu.container.meta.MetaGroup) Test(org.testng.annotations.Test)

Aggregations

MetaGroup (ml.shifu.shifu.container.meta.MetaGroup)3 Test (org.testng.annotations.Test)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 MetaItem (ml.shifu.shifu.container.meta.MetaItem)2