2 Replies Latest reply on Sep 25, 2017 7:39 AM by stevegr RSS
    dsödling Newbie

    Should it be possible to add rows to an InfoTable as part of a unit test?

    Dear all,


    I hesitate to ask this because it seems like it should be a really trivial thing but I can't seem to be able solve it on my own.


    I am simply trying to create a service that will remove duplicate rows from an InfoTable and as part of this endeavour I am trying to write a unit test to validate my service. The problem I have is that the InfoTable in my test never seems to have any data. I use the most obvious method (addRow) but that doesn't seem to do anything.


    I'm hoping that someone can tell me what it is that I'm missing. Is this type of unit testing not possible, am I using the wrong methods or is there some other setting I have to get right in order to get this to work? My code is the following


    public class PDSUtilTest {
        public void test() throws Exception {
            PDSUtil instance = new PDSUtil();
            DataShapeDefinition dsd = new DataShapeDefinition();
            InfoTable data;
            InfoTable result;
            dsd.addFieldDefinition(new FieldDefinition("desc", BaseTypes.STRING));
            dsd.addFieldDefinition(new FieldDefinition("type", BaseTypes.STRING));
            dsd.addFieldDefinition(new FieldDefinition("time", BaseTypes.STRING));
            data = new InfoTable(dsd);
            addRow(data, "simple-alert", "A duplicate alert.", "2017-08-31 16:44");
            addRow(data, "simple-alert", "A duplicate alert.", "2017-08-31 16:44");
            addRow(data, "simple-alert", "A simple alert of some other sort sort.", "2017-08-31 16:44");
            addRow(data, "simple-alert", "A simple alert of some other sort sort.", "2017-08-31 16:45");
            for (int i = 0; i < data.getRowCount(); i++) {
            result = instance.getUniqueRows(data, "type,desc,time");
            assertTrue("Expected one row to have been removed", result.getLength() == 3);
        private void addRow(InfoTable data, String type, String desc, String time) throws Exception {
            int count = data.addRow(getRow(type,desc, time).clone());
            System.out.println("Count: " + count);
        private ValueCollection getRow(String type, String desc, String time) throws Exception {
            ValueCollection row = new ValueCollection();
            row.SetStringValue("type", type);
            row.SetStringValue("desc", desc);
            row.SetStringValue("time", time);
            System.out.println("row: " + row);
            return row;


    Best regards

    Daniel Södling