es.upm.dit.gsi.beast.reader
Class Reader

java.lang.Object
  extended by es.upm.dit.gsi.beast.reader.Reader
Direct Known Subclasses:
MASReader, SystemReader

public class Reader
extends Object

Project: beast File: es.upm.dit.gsi.beast.reader.Reader.java Main class to transform the plain text given by the client to the necessary classes to run each Test. These classes are the Scenario, Setup and Evaluation, which emulate the GIVEN, WHEN and THEN parts of the plain text; the .story file whit the plain text of the test and the its .java class with the same name to interpret it. Furthermore, one casemanager must be created, which will run all the tests. Grupo de Sistemas Inteligentes Departamento de Ingeniería de Sistemas Telemáticos Universidad Politécnica de Madrid (UPM)

Version:
0.2
Author:
Jorge Solitario, Alberto Mardomingo, alvarocarrera

Field Summary
static String MAS
          Multi Agent System Test Reader
static String SYSTEM
          System Test Reader
 
Constructor Summary
Reader()
           
 
Method Summary
static String changeFirstLetterToCapital(String word)
          Method used to write the name of the scenarios
static String changeFirstLetterToLowerCase(String word)
          Method used to write the name of the scenarios methods
static String createClassName(String scenarioDescription)
          Given a string with the scenario or story name, creates a Class Name with no spaces and first letter capital
static void createDotStoryFile(String scenarioName, String srcTestRootFolder, String packagePath, String givenDescription, String whenDescription, String thenDescription)
          Creates the .story file necessary for every Beast Test Case.
protected static String createDotStoryName(String scenarioName)
          Creates the name of the .story file to be wrote with the testcase.
protected static BufferedReader createFileReader(String file_name)
          Method to read our client's plain text
protected static FileWriter createFileWriter(String scenarioName, String aux_package_path, String dest_dir)
          Method to get the file writer required for the .story files
static String createFirstLowCaseName(String scenarioDescription)
          Given a string with method or package name, creates a Class Name with no spaces and first letter lower case
static File createFolder(String path, String dest_dir)
          This method returns the existing folder, and if it does not exist, the method generates it.
static String createFolderPath(String path)
          This method changes package_path into folder's path
protected static String createTestPath(String aux_package_path, String scenarioName)
          This method will generate the paths that casemanager must include in its code
protected static boolean fileDoesNotExist(String file, String path, String dest_dir)
          Method to know if already exists one file with the same name in the same folder
static void generateJavaFiles(String requirementsFolder, String platformName, String src_test_dir, String tests_package, String casemanager_package, String loggingPropFile, String specificationPhase)
          Main method of the class, which handles all the process to create all tests.
static void main(String[] args)
          Main method to start reading the plain text given by the client
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAS

public static final String MAS
Multi Agent System Test Reader

See Also:
Constant Field Values

SYSTEM

public static final String SYSTEM
System Test Reader

See Also:
Constant Field Values
Constructor Detail

Reader

public Reader()
Method Detail

generateJavaFiles

public static void generateJavaFiles(String requirementsFolder,
                                     String platformName,
                                     String src_test_dir,
                                     String tests_package,
                                     String casemanager_package,
                                     String loggingPropFile,
                                     String specificationPhase)
                              throws Exception
Main method of the class, which handles all the process to create all tests.

Parameters:
requirementsFolder - , it is the folder where the plain text given by the client is stored
platformName - , to choose the MAS platform (JADE, JADEX, etc.)
src_test_dir - , the folder where our classes are created
tests_package - , the name of the package where the stories are created
casemanager_package - , the path where casemanager must be created
loggingPropFile - , properties file
specificationPhase - , the Type of reader (MAS or SYSTEM). By default, uses a MAS Reader
Throws:
Exception - , if any error is found in the configuration

changeFirstLetterToCapital

public static String changeFirstLetterToCapital(String word)
Method used to write the name of the scenarios

Parameters:
word -
Returns:
the same word starting with capital letter

changeFirstLetterToLowerCase

public static String changeFirstLetterToLowerCase(String word)
Method used to write the name of the scenarios methods

Parameters:
word -
Returns:
the same word starting with lower case

createClassName

public static String createClassName(String scenarioDescription)
Given a string with the scenario or story name, creates a Class Name with no spaces and first letter capital

Parameters:
String - - The name of the scenario/story. It should be in lower case.

createFirstLowCaseName

public static String createFirstLowCaseName(String scenarioDescription)
Given a string with method or package name, creates a Class Name with no spaces and first letter lower case

Parameters:
String - - The name of the scenario/story. It should be in lower case.

fileDoesNotExist

protected static boolean fileDoesNotExist(String file,
                                          String path,
                                          String dest_dir)
Method to know if already exists one file with the same name in the same folder

Parameters:
scenario_name -
path -
dest_dir -
Returns:
true when the file does not exist

createFolder

public static File createFolder(String path,
                                String dest_dir)
                         throws BeastException
This method returns the existing folder, and if it does not exist, the method generates it.

Parameters:
path -
dest_dir -
Returns:
the folder
Throws:
BeastException

createFolderPath

public static String createFolderPath(String path)
This method changes package_path into folder's path

Parameters:
path - , as es.upm.gsi
Returns:
the new path, es/upm/gsi

createTestPath

protected static String createTestPath(String aux_package_path,
                                       String scenarioName)
This method will generate the paths that casemanager must include in its code

Parameters:
aux_package_path - the path of the .story files, similar than es.upm.dit.gsi...
scenarioName -
Returns:
the new path, similar than es.upm.dit.gsi...

createFileReader

protected static BufferedReader createFileReader(String file_name)
                                          throws BeastException
Method to read our client's plain text

Parameters:
file_name -
Returns:
the filereader to translate client's plain text into our files
Throws:
BeastException - if any problem is found whit the file

createDotStoryFile

public static void createDotStoryFile(String scenarioName,
                                      String srcTestRootFolder,
                                      String packagePath,
                                      String givenDescription,
                                      String whenDescription,
                                      String thenDescription)
                               throws BeastException
Creates the .story file necessary for every Beast Test Case.

Parameters:
scenarioName - - The name of the scenario, with spaces
srcTestRootFolder - - The test root folder
packagePath - - The package of the BeastTestCase
scenarioDescription - - the scenario name
givenDescription - - The given description
whenDescription - - The when description
thenDescription - - The then description
Throws:
BeastException

createFileWriter

protected static FileWriter createFileWriter(String scenarioName,
                                             String aux_package_path,
                                             String dest_dir)
                                      throws BeastException
Method to get the file writer required for the .story files

Parameters:
scenarioName -
aux_package_path -
dest_dir -
Returns:
The file writer that generates the .story files for each test
Throws:
BeastException

createDotStoryName

protected static String createDotStoryName(String scenarioName)
Creates the name of the .story file to be wrote with the testcase. The name of the scenario must be given with spaces.

Parameters:
scenarioName - - The scenario name, with spaces
Returns:
the .story file name.

main

public static void main(String[] args)
                 throws Exception
Main method to start reading the plain text given by the client

Parameters:
args - , where arg[0] is Beast configuration file (beast.properties) and arg[1] is Logger configuration file (logger.properties)
Throws:
Exception


Copyright © 2014 Grupo de Sistemas Inteligentes - Universidad Politécnica de Madrid. All Rights Reserved.