public class MongoTestDAO extends Object implements LifecycleListener
| Modifier and Type | Field and Description |
|---|---|
static String |
COLLECTION_TEST_DEFS |
static String |
COLLECTION_TEST_DRIVERS |
static String |
COLLECTION_TEST_PROPS |
static String |
COLLECTION_TEST_RUNS |
static String |
COLLECTION_TESTS |
| Constructor and Description |
|---|
MongoTestDAO(com.mongodb.DB db)
Construct the DAO using the Mongo DB directly
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTestRunDriver(org.bson.types.ObjectId runObjId,
String driverId)
Register a driver with a test run
|
boolean |
copyTest(String test,
String release,
Integer schema,
String copyOfTest,
int copyOfVersion)
Create a new test by copying an existing test.
|
boolean |
copyTestRun(String test,
String run,
String copyOfRun,
int copyOfVersion)
Create a new test run by copying an existing test run.
|
long |
countDrivers(String release,
Integer schema,
boolean active)
Count registered drivers
|
boolean |
createTest(String test,
String description,
String release,
Integer schema)
Create a new test for the precise release and schema
|
boolean |
createTestRun(String test,
String run,
String description)
Create a new test run
|
com.mongodb.DBObject |
decryptPropertyValue(com.mongodb.DBObject dbObject,
String propName)
Decrypt property if encrypted
|
boolean |
deleteTest(String test)
Delete an existing test
|
boolean |
deleteTestRun(org.bson.types.ObjectId runObjId)
Delete an existing test run
|
boolean |
deleteTestRun(String test,
String run)
Delete an existing test run
|
com.mongodb.DBObject |
encryptPropertyValue(com.mongodb.DBObject dbObject,
String propName)
Encrypts property DB object
|
com.mongodb.DBObject |
exportTest(String testName)
Exports the test with properties as JSON
|
com.mongodb.DBObject |
exportTestRun(String testName,
String runName)
Exports a test run with encrypted password properties by test and run
name.
|
com.mongodb.DB |
getDb() |
com.mongodb.DBCursor |
getDrivers(String release,
Integer schema,
boolean active)
Get registered test drivers
|
Set<String> |
getMaskedProperyNames(String testName)
Fetch masked property names (passwords) by test name.
|
Set<String> |
getMaskedProperyNames(String release,
Integer schema)
Fetch masked property names (passwords) by release and version name.
|
com.mongodb.DBObject |
getProperty(String test,
String run,
String propertyName)
Retrieve the effective property for a given test, test run and property
name.
|
String |
getPropValueAsString(com.mongodb.DBObject dbPropertyObj)
Returns the value or default of the property as string
|
com.mongodb.DBObject |
getTest(org.bson.types.ObjectId testObjId,
boolean includeProperties)
Retrieve the data for given test
|
com.mongodb.DBObject |
getTest(String test,
boolean includeProperties)
Retrieve the data for given test
|
com.mongodb.DBObject |
getTestDef(String release,
Integer schema)
Retrieve a specific (and full) test definition
|
com.mongodb.DBCursor |
getTestDefs(boolean active,
int skip,
int count) |
Map<String,com.mongodb.DBObject> |
getTestPropertiesMap(org.bson.types.ObjectId testObjId,
String testName)
Returns the map with "final" test run properties of the test run.
|
com.mongodb.DBObject |
getTestRun(org.bson.types.ObjectId runObjId,
boolean includeProperties)
Retrieve the data for given test run
|
com.mongodb.DBObject |
getTestRun(String test,
String run,
boolean includeProperties)
Retrieve the data for given test run
|
List<String> |
getTestRunNames(String test)
Get the test run names associated with a given test
|
Map<String,com.mongodb.DBObject> |
getTestRunPropertiesMap(org.bson.types.ObjectId testObjId,
org.bson.types.ObjectId runObjId,
String testName,
String testRunName)
Returns the map with "final" test run properties of the test run.
|
com.mongodb.DBCursor |
getTestRuns(String test,
int skip,
int count,
TestRunState... testRunStates) |
com.mongodb.DBCursor |
getTests(String release,
Integer schema,
int skip,
int count)
Get a list of all defined tests
|
com.mongodb.DBObject |
importTest(String testName,
com.mongodb.DBObject importObj)
Imports the properties of a test from JSON.
|
com.mongodb.DBObject |
importTestRun(String testName,
String runName,
com.mongodb.DBObject importObj) |
boolean |
isMaskedProperty(com.mongodb.DBObject property)
Checks if the DBObject contains a field FIELD_MASK and returns true if
set
|
void |
lockProperties(org.bson.types.ObjectId testObjId,
org.bson.types.ObjectId runObjId)
Record a final set of locked properties for a test run.
|
void |
refreshDriver(String id,
long expiryTime)
Refresh the expiry time of a driver
|
String |
registerDriver(String release,
Integer schema,
String ipAddress,
String hostname,
String contextPath,
Set<String> capabilities)
Register a test driver
|
void |
removeTestRunDriver(org.bson.types.ObjectId runObjId,
String driverId)
Derigister a driver from a test run
|
boolean |
setPropertyOverride(String test,
String run,
String propertyName,
int version,
String value)
Override a specific test property value.
|
void |
start()
Initialize indexes
|
void |
stop() |
void |
unregisterDriver(String id)
Unregister a test driver
|
boolean |
updateTest(String name,
int version,
String newName,
String newDescription,
String newRelease,
Integer newSchema)
Update an existing test to use new test details
|
boolean |
updateTestRun(String test,
String run,
int version,
String newName,
String newDescription)
Update an existing test run with new details
|
boolean |
updateTestRunState(org.bson.types.ObjectId runId,
int version,
TestRunState testRunState,
Long scheduled,
Long started,
Long stopped,
Long completed,
Long duration,
Double progress,
Long resultsSuccess,
Long resultsFail)
Update the run state of a test run.
|
boolean |
writeTestDef(String release,
Integer schema,
String description,
List<TestProperty> testProperties)
Write all the test application's property definitions against the release
and schema number
|
public static final String COLLECTION_TEST_DEFS
public static final String COLLECTION_TEST_DRIVERS
public static final String COLLECTION_TESTS
public static final String COLLECTION_TEST_PROPS
public static final String COLLECTION_TEST_RUNS
public MongoTestDAO(com.mongodb.DB db)
public com.mongodb.DB getDb()
public void start()
start in interface LifecycleListenerpublic void stop()
stop in interface LifecycleListenerpublic String registerDriver(String release, Integer schema, String ipAddress, String hostname, String contextPath, Set<String> capabilities)
release - the software release versionschema - the schema numberipAddress - the IP address of the machine the application is running oncontextPath - the application context path (or similar) for informationcapabilities - the features supported by the driverpublic void refreshDriver(String id, long expiryTime)
id - the driver idexpiryTime - the new expiry timepublic void unregisterDriver(String id)
id - the ID of the registrationpublic com.mongodb.DBCursor getDrivers(String release, Integer schema, boolean active)
release - the release name of the test or null for all releasesschema - the schema number of the driver or null for all schemaspublic long countDrivers(String release, Integer schema, boolean active)
release - the release name of the test or null for all releasesschema - the schema number of the driver or null for all schemasliveOnly - true to retrieve only live instancespublic boolean writeTestDef(String release, Integer schema, String description, List<TestProperty> testProperties)
release - the test release nameschema - the property schemadescription - a description of the test definitiontestProperties - the property definitionspublic com.mongodb.DBCursor getTestDefs(boolean active,
int skip,
int count)
count - the number of results to retrieve (must be greater than zero)public com.mongodb.DBObject getTestDef(String release, Integer schema)
release - the test definition software releaseschema - the schema numberpublic com.mongodb.DBCursor getTests(String release, Integer schema, int skip, int count)
release - the test definition software release or null for all test
releasesschema - the schema number or null for all schemaspublic com.mongodb.DBObject getTest(org.bson.types.ObjectId testObjId,
boolean includeProperties)
testObjId - the ID of the testincludeProperties - true to flesh out the propertiespublic com.mongodb.DBObject getTest(String test, boolean includeProperties)
test - the test nameincludeProperties - true to flesh out the propertiespublic boolean copyTest(String test, String release, Integer schema, String copyOfTest, int copyOfVersion)
name - a globally-unique name using
ConfigConstants#TEST_NAME_REGEXrelease - the test definition software release or null to use the
same release as the source testschema - the schema number or null to use the same schema as the
source testcopyOfTest - the test name to copycopyOfVersion - the version of the test to copypublic boolean createTest(String test, String description, String release, Integer schema)
test - a globally-unique name using
ConfigConstants#TEST_NAME_REGEXdescription - any descriptionrelease - the test definition software releaseschema - the schema numberpublic boolean updateTest(String name, int version, String newName, String newDescription, String newRelease, Integer newSchema)
name - the name of the test (must exist)version - the version of the test for concurrency checkingnewName - the new test namenewDescription - the new description or null ot leave itnewRelease - the new software release or null to leave itnewSchema - the new schema number or null to leave itpublic boolean deleteTest(String test)
test - the name of the test (must exist)public List<String> getTestRunNames(String test)
test - the name of the testpublic com.mongodb.DBCursor getTestRuns(String test, int skip, int count, TestRunState... testRunStates)
test - only fetch runs for this test or null to get all test
runstestRunStates - optional states that the test runs must be in or empty for allpublic com.mongodb.DBObject getTestRun(org.bson.types.ObjectId runObjId,
boolean includeProperties)
throws ObjectNotFoundException
runObjId - (ObjectId, mandatory) the ID of the test runincludeProperties - true to flesh out all the propertiesObjectNotFoundExceptionpublic Map<String,com.mongodb.DBObject> getTestRunPropertiesMap(org.bson.types.ObjectId testObjId, org.bson.types.ObjectId runObjId, String testName, String testRunName) throws ObjectNotFoundException
testObjId - (ObjectId, optional)runObjId - (ObjectId, optional)testName - (String, mandatory)testRunName - (String, mandatory)ObjectNotFoundExceptionpublic Map<String,com.mongodb.DBObject> getTestPropertiesMap(org.bson.types.ObjectId testObjId, String testName) throws ObjectNotFoundException
testObjId - (ObjectId, optional)testName - (String, mandatory)ObjectNotFoundExceptionpublic com.mongodb.DBObject getTestRun(String test, String run, boolean includeProperties) throws ObjectNotFoundException
test - (String, mandatory) the name of the testrun - (String, mandatory) the test run nameincludeProperties - true to flesh out all the propertiesObjectNotFoundExceptionpublic boolean copyTestRun(String test, String run, String copyOfRun, int copyOfVersion)
test - the name of the test to which the run belongsrun - a test-unique name using ConfigConstants#RUN_NAME_REGEXcopyOfRun - the test run name to copycopyOfVersion - the version of the test run to copypublic boolean createTestRun(String test, String run, String description)
test - the name of the test to which the run belongsrun - a test-unique name using ConfigConstants#RUN_NAME_REGEXdescription - any descriptionpublic boolean updateTestRun(String test, String run, int version, String newName, String newDescription)
test - the name of the testrun - the name of the test run (must exist)version - the version of the test for concurrency checkingnewName - the new name of the test runnewDescription - the new description or null ot leave itpublic boolean updateTestRunState(org.bson.types.ObjectId runId,
int version,
TestRunState testRunState,
Long scheduled,
Long started,
Long stopped,
Long completed,
Long duration,
Double progress,
Long resultsSuccess,
Long resultsFail)
state will be set based on
the values.
Note that a test run can either be stopped or completed but not both. In
both cases,
though, the test run must have been scheduled and then started.test - the name of the testrun - the name of the test run (must exist)version - the version of the test for concurrency checkingtestRunState - the test run state to set (scheduled - the time when the test run is scheduled to start (started - the time when the test run started (stopped - the time when the test run was stopped (completed - the time when the test run was completed (duration - the time the test has been running for in ms (progress - the new progress for the test run (resultsSuccess - the number of successful results (resultsFailure - the number of failed results (public void addTestRunDriver(org.bson.types.ObjectId runObjId,
String driverId)
runObjId - the ID of the test rundriverId - the ID of the driver to includepublic void removeTestRunDriver(org.bson.types.ObjectId runObjId,
String driverId)
runObjId - the ID of the test rundriverId - the ID of the driver to removepublic boolean deleteTestRun(org.bson.types.ObjectId runObjId)
runObjId - the ID of the test runpublic boolean deleteTestRun(String test, String run)
test - the name of the testrun - the run name (must exist)public com.mongodb.DBObject getProperty(String test, String run, String propertyName)
test - the name of the testrun - the name of the run or null to find the value for the
test onlypropertyName - the name of the property (never null)public boolean setPropertyOverride(String test, String run, String propertyName, int version, String value)
test - the name of the testrun - the name of the test run (null to reference the test
alone)propertyName - the name of the propertyversion - the current version of the propertyvalue - the new value to set or null to remove any overrideIllegalStateException - if the test has startedpublic void lockProperties(org.bson.types.ObjectId testObjId,
org.bson.types.ObjectId runObjId)
throws ObjectNotFoundException
testObjId - the ID of the testrunObjId - the ID of the test runObjectNotFoundExceptionpublic Set<String> getMaskedProperyNames(String release, Integer schema) throws ObjectNotFoundException
release - (String, mandatory) test release nameversion - (Integer) test version numberObjectNotFoundExceptionpublic boolean isMaskedProperty(com.mongodb.DBObject property)
property - (DBObject) propertypublic Set<String> getMaskedProperyNames(String testName) throws ObjectNotFoundException
testName - (String, mandatory) test nameObjectNotFoundExceptionpublic com.mongodb.DBObject importTest(String testName, com.mongodb.DBObject importObj)
testName - (String, mandatory) test name to import properties toimportObj - (DBObject, mandatory) properties to importpublic com.mongodb.DBObject importTestRun(String testName, String runName, com.mongodb.DBObject importObj)
public String getPropValueAsString(com.mongodb.DBObject dbPropertyObj)
dbPropertyObj - (DBObject) property to readpublic com.mongodb.DBObject exportTest(String testName) throws ObjectNotFoundException, CipherException
testName - (string, mandatory) name of the test to exportObjectNotFoundExceptionCipherExceptionpublic com.mongodb.DBObject exportTestRun(String testName, String runName) throws ObjectNotFoundException, CipherException
testName - (String, mandatory) test namerunName - (String, mandatory) run nameObjectNotFoundExceptionCipherExceptionpublic com.mongodb.DBObject encryptPropertyValue(com.mongodb.DBObject dbObject,
String propName)
throws CipherException
dbObject - (DBObject, mandatory)propName - (String, mandatory) name of the propertyCipherExceptionpublic com.mongodb.DBObject decryptPropertyValue(com.mongodb.DBObject dbObject,
String propName)
throws CipherException
dbObject - (DBObject, mandatory) Property, that might be encryptedpropName - (String, mandatory) Name of the propertyCipherExceptionCopyright © 2005–2018 Alfresco Software. All rights reserved.