Changeset 666 for trunk


Ignore:
Timestamp:
08/28/12 13:46:52 (12 years ago)
Author:
sherbold
Message:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-ui-core-test/src/test/java/de/ugoe/cs/quest/ui/GlobalDataContainerTest.java

    r655 r666  
    11package de.ugoe.cs.quest.ui; 
     2 
     3import static org.junit.Assert.assertEquals; 
     4import static org.junit.Assert.assertFalse; 
     5import static org.junit.Assert.assertNotNull; 
     6import static org.junit.Assert.assertNull; 
     7import static org.junit.Assert.assertSame; 
     8import static org.junit.Assert.assertTrue; 
     9import static org.junit.Assert.fail; 
    210 
    311import java.io.ByteArrayInputStream; 
     
    1018import java.util.Collection; 
    1119import java.util.LinkedList; 
    12 import java.util.List; 
    13  
    14 import org.junit.*; 
    15  
    16 import de.ugoe.cs.quest.eventcore.Event; 
    17 import de.ugoe.cs.quest.usageprofiles.IStochasticProcess; 
    18  
    19 import static org.junit.Assert.*; 
    20 import static org.mockito.Mockito.*; 
     20 
     21import org.junit.Before; 
     22import org.junit.Test; 
    2123 
    2224/** 
     
    240242 
    241243    @Test 
    242     public void testGetAllSequencesNames_1() { 
    243         GlobalDataContainer instance = GlobalDataContainer.getInstance(); 
    244         String key1 = "key1"; 
    245         String data1 = "data1"; 
    246         String key2 = "key2"; 
    247         String data2 = "data2"; 
    248         String key3 = "key3"; 
    249         Integer data3 = 1; 
    250         String key4 = "key4"; 
    251         Integer data4 = 2; 
    252         String key5 = "key5"; 
    253         Integer data5 = 3; 
    254  
    255         assertFalse(instance.addData(key1, data1)); 
    256         assertFalse(instance.addData(key2, data2)); 
    257         assertFalse(instance.addData(key3, data3)); 
    258         assertFalse(instance.addData(key4, data4)); 
    259         assertFalse(instance.addData(key5, data5)); 
    260  
    261         String keySeq1 = "seq1"; 
    262         Collection<List<Event>> seq1 = new LinkedList<List<Event>>(); 
    263         List<Event> subseq1 = new LinkedList<Event>(); 
    264         subseq1.add(Event.STARTEVENT); 
    265         seq1.add(subseq1); 
    266  
    267         String keySeq2 = "seq2"; 
    268         Collection<List<Event>> seq2 = new LinkedList<List<Event>>(); 
    269         List<Event> subseq2 = new LinkedList<Event>(); 
    270         subseq2.add(Event.STARTEVENT); 
    271         seq2.add(subseq2); 
    272  
    273         assertFalse(instance.addData(keySeq1, seq1)); 
    274         assertFalse(instance.addData(keySeq2, seq2)); 
    275  
    276         Collection<String> expected = new LinkedList<String>(); 
    277         expected.add(keySeq1); 
    278         expected.add(keySeq2); 
    279  
    280         assertCollectionContent(expected, instance.getAllSequencesNames()); 
    281     } 
    282  
    283     @Test 
    284     public void testGetAllSequencesNames_2() { 
    285         GlobalDataContainer instance = GlobalDataContainer.getInstance(); 
    286         String key1 = "key1"; 
    287         String data1 = "data1"; 
    288         String key2 = "key2"; 
    289         String data2 = "data2"; 
    290         String key3 = "key3"; 
    291         Integer data3 = 1; 
    292         String key4 = "key4"; 
    293         Integer data4 = 2; 
    294         String key5 = "key5"; 
    295         Integer data5 = 3; 
    296  
    297         assertFalse(instance.addData(key1, data1)); 
    298         assertFalse(instance.addData(key2, data2)); 
    299         assertFalse(instance.addData(key3, data3)); 
    300         assertFalse(instance.addData(key4, data4)); 
    301         assertFalse(instance.addData(key5, data5)); 
    302  
    303         String keySeq1 = "seq1"; 
    304         Collection<List<Event>> seq1 = new LinkedList<List<Event>>(); 
    305         List<Event> subseq1 = new LinkedList<Event>(); 
    306         subseq1.add(Event.STARTEVENT); 
    307         seq1.add(subseq1); 
    308  
    309         String keySeq2 = "seq2"; 
    310         Collection<List<Event>> seq2 = new LinkedList<List<Event>>(); 
    311  
    312         assertFalse(instance.addData(keySeq1, seq1)); 
    313         assertFalse(instance.addData(keySeq2, seq2)); 
    314  
    315         Collection<String> expected = new LinkedList<String>(); 
    316         expected.add(keySeq1); 
    317  
    318         assertCollectionContent(expected, instance.getAllSequencesNames()); 
    319     } 
    320  
    321     @Test 
    322     public void testGetAllSequencesNames_3() { 
    323         GlobalDataContainer instance = GlobalDataContainer.getInstance(); 
    324         String key1 = "key1"; 
    325         String data1 = "data1"; 
    326         String key2 = "key2"; 
    327         String data2 = "data2"; 
    328         String key3 = "key3"; 
    329         Integer data3 = 1; 
    330         String key4 = "key4"; 
    331         Integer data4 = 2; 
    332         String key5 = "key5"; 
    333         Integer data5 = 3; 
    334  
    335         assertFalse(instance.addData(key1, data1)); 
    336         assertFalse(instance.addData(key2, data2)); 
    337         assertFalse(instance.addData(key3, data3)); 
    338         assertFalse(instance.addData(key4, data4)); 
    339         assertFalse(instance.addData(key5, data5)); 
    340  
    341         Collection<String> expected = new LinkedList<String>(); 
    342  
    343         assertCollectionContent(expected, instance.getAllSequencesNames()); 
    344     } 
    345  
    346     @Test 
    347     public void testGetAllModelNames_1() { 
    348         GlobalDataContainer instance = GlobalDataContainer.getInstance(); 
    349         String key1 = "key1"; 
    350         String data1 = "data1"; 
    351         String key2 = "key2"; 
    352         String data2 = "data2"; 
    353         String key3 = "key3"; 
    354         Integer data3 = 1; 
    355         String key4 = "key4"; 
    356         Integer data4 = 2; 
    357         String key5 = "key5"; 
    358         Integer data5 = 3; 
    359  
    360         assertFalse(instance.addData(key1, data1)); 
    361         assertFalse(instance.addData(key2, data2)); 
    362         assertFalse(instance.addData(key3, data3)); 
    363         assertFalse(instance.addData(key4, data4)); 
    364         assertFalse(instance.addData(key5, data5)); 
    365  
    366         String modelKey1 = "model1"; 
    367         IStochasticProcess model1 = mock(IStochasticProcess.class); 
    368         String modelKey2 = "model2"; 
    369         IStochasticProcess model2 = mock(IStochasticProcess.class); 
    370  
    371         assertFalse(instance.addData(modelKey1, model1)); 
    372         assertFalse(instance.addData(modelKey2, model2)); 
    373  
    374         Collection<String> expected = new LinkedList<String>(); 
    375         expected.add(modelKey1); 
    376         expected.add(modelKey2); 
    377  
    378         assertCollectionContent(expected, instance.getAllModelNames()); 
    379     } 
    380  
    381     @Test 
    382     public void testGetAllModelNames_2() { 
    383         GlobalDataContainer instance = GlobalDataContainer.getInstance(); 
    384         String key1 = "key1"; 
    385         String data1 = "data1"; 
    386         String key2 = "key2"; 
    387         String data2 = "data2"; 
    388         String key3 = "key3"; 
    389         Integer data3 = 1; 
    390         String key4 = "key4"; 
    391         Integer data4 = 2; 
    392         String key5 = "key5"; 
    393         Integer data5 = 3; 
    394  
    395         assertFalse(instance.addData(key1, data1)); 
    396         assertFalse(instance.addData(key2, data2)); 
    397         assertFalse(instance.addData(key3, data3)); 
    398         assertFalse(instance.addData(key4, data4)); 
    399         assertFalse(instance.addData(key5, data5)); 
    400  
    401         Collection<String> expected = new LinkedList<String>(); 
    402  
    403         assertCollectionContent(expected, instance.getAllModelNames()); 
    404     } 
    405  
    406     @Test 
    407244    public void testSerialization_1() throws Exception { 
    408245        GlobalDataContainer instance = GlobalDataContainer.getInstance(); 
  • trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/ui/GlobalDataContainer.java

    r658 r666  
    77import java.util.Collection; 
    88import java.util.HashMap; 
    9 import java.util.LinkedList; 
    109import java.util.Map; 
    11 import java.util.Map.Entry; 
    12  
    13 import de.ugoe.cs.quest.SequenceInstanceOf; 
    14 import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 
    15 import de.ugoe.cs.quest.usageprofiles.IStochasticProcess; 
    1610 
    1711/** 
     
    181175        /** 
    182176         * <p> 
    183          * Returns all keys of collections of sequences contained in the storage. 
    184          * </p> 
    185          *  
    186          * @return keys of all collections of sequences contained in the storage 
    187          */ 
    188         public Collection<String> getAllSequencesNames() { 
    189                 Collection<String> allSequencesNames = new LinkedList<String>(); 
    190                 for (Entry<String, Object> entry : dataObjects.entrySet()) { 
    191                         if( SequenceInstanceOf.isCollectionOfSequences(entry.getValue())) { 
    192                                 allSequencesNames.add(entry.getKey()); 
    193                         } 
    194                 } 
    195                 return allSequencesNames; 
    196         } 
    197  
    198         /** 
    199          * <p> 
    200          * Returns the keys of all {@link IStochasticProcess}s contained in the 
    201          * storage. 
    202          * </p> 
    203          *  
    204          * @return keys of all {@link IStochasticProcess}s contained in the storage 
    205          */ 
    206         public Collection<String> getAllModelNames() { 
    207                 Collection<String> modelNames = new LinkedList<String>(); 
    208                 for (Entry<String, Object> entry : dataObjects.entrySet()) { 
    209                         if (entry.getValue() instanceof IStochasticProcess) { 
    210                                 modelNames.add(entry.getKey()); 
    211                         } 
    212                 } 
    213                 return modelNames; 
    214         } 
    215          
    216         /** 
    217          * <p> 
    218          * Returns the keys of all {@link GUIModel}s contained in the storage. 
    219          * </p> 
    220          * 
    221          * @return keys of all {@link GUIModel}s contained in the storage 
    222          */ 
    223         public Collection<String> getAllGUIModelNames() { 
    224             Collection<String> modelNames = new LinkedList<String>(); 
    225             for(Entry<String, Object> entry : dataObjects.entrySet()) { 
    226                 if( entry.getValue() instanceof GUIModel ) { 
    227                     modelNames.add(entry.getKey()); 
    228                 } 
    229             } 
    230             return modelNames; 
    231         } 
    232  
    233         /** 
    234          * <p> 
    235177         * Returns the keys of all objects contained in the storage. 
    236178         * </p> 
  • trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/GuiModelTabComposite.java

    r658 r666  
    8585    public void updateModelList() { 
    8686        guiModelList.removeAll(); 
    87         for (String modelName : GlobalDataContainer.getInstance().getAllGUIModelNames()) { 
    88             guiModelList.add(modelName); 
     87        for(String key : GlobalDataContainer.getInstance().getAllKeys()) { 
     88            if( GlobalDataContainer.getInstance().getData(key) instanceof GUIModel ) { 
     89                guiModelList.add(key); 
     90            } 
    8991        } 
    9092    } 
  • trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/ModelsTabComposite.java

    r655 r666  
    150150    public void updateModelList() { 
    151151        modelList.removeAll(); 
    152         for (String sequencesName : GlobalDataContainer.getInstance().getAllModelNames()) { 
    153             modelList.add(sequencesName); 
     152        for(String key : GlobalDataContainer.getInstance().getAllKeys()) { 
     153            if( GlobalDataContainer.getInstance().getData(key) instanceof IStochasticProcess ) { 
     154                modelList.add(key); 
     155            } 
    154156        } 
    155157    } 
  • trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/SequencesTabComposite.java

    r655 r666  
    1313import org.eclipse.swt.events.SelectionEvent; 
    1414 
     15import de.ugoe.cs.quest.SequenceInstanceOf; 
    1516import de.ugoe.cs.quest.ui.GlobalDataContainer; 
    1617import de.ugoe.cs.util.console.CommandExecuter; 
     
    129130    public void updateSequenceList() { 
    130131        sequenceList.removeAll(); 
    131         for (String sequencesName : GlobalDataContainer.getInstance().getAllSequencesNames()) { 
    132             sequenceList.add(sequencesName); 
     132        for(String key : GlobalDataContainer.getInstance().getAllKeys()) { 
     133            if( SequenceInstanceOf.isCollectionOfSequences(GlobalDataContainer.getInstance().getData(key)) ) { 
     134                sequenceList.add(key); 
     135            } 
    133136        } 
    134137    } 
Note: See TracChangeset for help on using the changeset viewer.