Search in sources :

Example 6 with ModelList

use of com.github.noraui.model.ModelList in project NoraUi by NoraUi.

the class ArticleUT method checkgetModelListTest.

@Test
public void checkgetModelListTest() throws InstantiationException, IllegalAccessException {
    // prepare mock
    Article football = new Article();
    football.setTitle("Football");
    football.setText("Football is a family of team sports...");
    football.setAuthor("wikipedia");
    football.setNote(8);
    Article judo = new Article();
    judo.setTitle("Judo");
    judo.setText("Judo was created as a physical, mental and moral pedagogy in Japan, in 1882, by Kanō Jigorō...");
    judo.setAuthor("wikipedia");
    judo.setNote(10);
    Class<? extends ModelList> c = football.getModelList();
    ModelList cl = c.newInstance();
    cl.addModel(football);
    cl.addModel(judo);
    // run test
    Assert.assertEquals("[{\"title\":\"Football\",\"text\":\"Football is a family of team sports...\",\"author\":\"wikipedia\",\"note\":8},{\"title\":\"Judo\",\"text\":\"Judo was created as a physical, mental and moral pedagogy in Japan, in 1882, by Kanō Jigorō...\",\"author\":\"wikipedia\",\"note\":10}]", cl.serialize());
}
Also used : ModelList(com.github.noraui.model.ModelList) Test(org.junit.Test)

Aggregations

ModelList (com.github.noraui.model.ModelList)6 TechnicalException (com.github.noraui.exception.TechnicalException)3 Model (com.github.noraui.model.Model)3 DataIndex (com.github.noraui.data.DataIndex)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 LinkedHashMap (java.util.LinkedHashMap)1 InvalidFileFormatException (org.ini4j.InvalidFileFormatException)1