source: trunk/autoquest-plugin-guitar/src/main/java/de/ugoe/cs/autoquest/plugin/guitar/commands/CMDefgTestCasesToSequences.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 2.8 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.plugin.guitar.commands;
16
17import java.io.File;
18import java.io.FilenameFilter;
19import java.util.Collection;
20import java.util.LinkedList;
21import java.util.List;
22import java.util.logging.Level;
23
24import de.ugoe.cs.autoquest.CommandHelpers;
25import de.ugoe.cs.autoquest.eventcore.Event;
26import de.ugoe.cs.autoquest.plugin.guitar.GUITARTestCaseParser;
27import de.ugoe.cs.util.console.Command;
28import de.ugoe.cs.util.console.Console;
29import de.ugoe.cs.util.console.GlobalDataContainer;
30
31/**
32 * <p>
33 * Command to load a set of sequences from a set of GUITAR test cases.
34 * </p>
35 *
36 * @author Steffen Herbold
37 * @version 1.0
38 */
39public class CMDefgTestCasesToSequences implements Command {
40
41        /*
42         * (non-Javadoc)
43         *
44         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
45         */
46        @Override
47        public void run(List<Object> parameters) {
48                String foldername;
49                String sequencesName;
50                String efgFileName = null;
51                try {
52                        foldername = (String) parameters.get(0);
53                        sequencesName = (String) parameters.get(1);
54                        if (parameters.size() >= 3) {
55                                efgFileName = (String) parameters.get(2);
56                        }
57                } catch (Exception e) {
58                        throw new IllegalArgumentException();
59                }
60
61                File folder = new File(foldername);
62               
63                File[] testcaseFiles = folder.listFiles( new FilenameFilter() {
64                        @Override
65                        public boolean accept(File dir, String name) {
66                                return name.endsWith(".tst");
67                        }
68                });
69                Collection<List<Event>> sequences = new LinkedList<List<Event>>();
70                GUITARTestCaseParser parser;
71                if (efgFileName == null) {
72                        parser = new GUITARTestCaseParser();
73                } else {
74                        parser = new GUITARTestCaseParser(efgFileName);
75                }
76                for (File testcaseFile : testcaseFiles) {
77                        Console.traceln(Level.INFO, "Loading from file "
78                                        + testcaseFile.getAbsolutePath());
79                        sequences.add(parser.parseTestCaseFile(testcaseFile));
80                }
81                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
82                        CommandHelpers.dataOverwritten(sequencesName);
83                }
84
85        }
86
87        /*
88         * (non-Javadoc)
89         *
90         * @see de.ugoe.cs.util.console.Command#help()
91         */
92        @Override
93        public String help() {
94                return "efgTestCasesToSequences <directory> <sequencesName> {<guiFileName>}";
95        }
96
97}
Note: See TracBrowser for help on using the repository browser.