Package eu.iv4xr.framework.mainConcepts
Class TestDataCollector
java.lang.Object
eu.iv4xr.framework.mainConcepts.TestDataCollector
- All Implemented Interfaces:
Parsable
This class is used to collect information from one or more test-agents.
Test-agents collect information in the form of instances of
ObservationEvent
that they then send to a TestDataCollector. Such a
collector collects three types of data:
- Time-stamped events. These are instances of
ObservationEvent.TimeStampedObservationEvent
. They are stored chronologically in a list and is useful for debugging. E.g. when a negative verdict is observed, we can see in this list what are the events that preceed it. - Verdicts. These are a special kind of time-stamped events that report things that the agent observed as correct as well as as wrong.
- Coverage events. These are instances of
ObservationEvent.CoveragePointEvent
representing the coverage-points the test-agent manage to cover.
- Author:
- Wish
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
This class is used to keep track which coverage-points were visited.(package private) static class
This class is used to hold a chronological list of time-stamped events. -
Field Summary
Modifier and TypeFieldDescriptionprotected TestDataCollector.CoverageMap
The cummulative coverage-map of all agents.protected Map<String,TestDataCollector.CoverageMap>
The coverage-map of each agent.protected Map<String,TestDataCollector.EventTrace>
The trace of time-stamped events of each agent. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn a map describing which coverage-points were collectively covered all test-agents registered to this TestDataCollector.Get the last reported negative verdict.getLastFailVerdict(String agentUniqueId)
Get the last negative verdict reported by the specified test-agent.int
Get the total number of negative verdicts reported by all test-agents.int
getNumberOfFailVerdictsSeen(String agentUniqueId)
Get the number of negative verdicts reported by the specified test-agent.int
Get the total number of positive verdicts reported by all test-agents.int
getNumberOfPassVerdictsSeen(String agentUniqueId)
Get the number of positive verdicts reported by the specified test-agent.int
Get the total number of undecided verdicts reported by all test-agents.int
getNumberOfUndecidedVerdictsSeen(String agentUniqueId)
Get the number of undecided verdicts reported by the specified test-agent.getTestAgentCoverage(String agentUniqueId)
Return a map describing which coverage-points were covered by the specified agent.getTestAgentScalarsTrace(String agentUniqueId)
Return the trace of the specified agent, containing only of ScalarTracingEvents.getTestAgentTrace(String agentUniqueId)
Return the "trace" of the specified test-agent.merge(TestDataCollector data2)
Merge two sets of collected test data.static TestDataCollector
readCollectedTestData(File file)
Read collected test data from a file.void
registerEvent(String agentUniqueId, ObservationEvent.TimeStampedObservationEvent e)
Register an observation event.void
registerTestAgent(String agentUniqueId)
Register a test-agent to this data collector.void
registerVisit(String agentUniqueId, ObservationEvent.CoveragePointEvent e)
Register a visit to a coverage-point by a test-agent.void
reset()
Reset the agents' traces recorded in this data-collector, and also reset all coverage information tracked by this data-collector (that means reseting their visit-counts to 0).void
Save the data collected to files.void
saveTestAgentScalarsTraceAsCSV(String agentUniqueId, String filename)
Export the scalar-trace of an agent to a CSV-file.void
startTrackingCoveragePoint(String coveragePointId)
Add a coverage-point to the set of coverage-points whose coverage will be tracked.toString()
-
Field Details
-
perAgentCoverage
The coverage-map of each agent. By "each agent" we mean a test-agent that has been registered to this TestDataCollector. -
collectiveCoverageMap
The cummulative coverage-map of all agents. By "agents" we mean the test-agents that have been registered to this TestDataCollector. -
perAgentEventTrace
The trace of time-stamped events of each agent.
-
-
Constructor Details
-
TestDataCollector
public TestDataCollector()
-
-
Method Details
-
startTrackingCoveragePoint
Add a coverage-point to the set of coverage-points whose coverage will be tracked. -
registerTestAgent
Register a test-agent to this data collector. We do not literally pass a test-agent, but rather its id.- Parameters:
agentUniqueId
- The id of the agent. This is assumed to be unique.
-
registerVisit
Register a visit to a coverage-point by a test-agent.- Parameters:
agentUniqueId
- Unique id of the test-agent.e
- An event representing the visit to some coverage point of interest.
-
registerEvent
Register an observation event. This allows a test-agent to register whatever event of interest to this data collector. This will be recorded into the agent's trace. Note that an event can also be a verdict-event, where the test agent reports that it has seen something that is either according to its expectation, or violating it.- Parameters:
agentUniqueId
- Unique id of the test-agent.e
- An event representing the observation to record.
-
getTestAgentCoverage
Return a map describing which coverage-points were covered by the specified agent. If m is the returned map, it maps a set ofObservationEvent.CoveragePointEvent
to integers. Each coverage-point-event in the map represents a unique coverage-point to track. The integer it is mapped to is the number of times the coverage-point is visited. -
getCollectiveCoverage
Return a map describing which coverage-points were collectively covered all test-agents registered to this TestDataCollector. If m is the returned map, it maps a set ofObservationEvent.CoveragePointEvent
to integers. Each coverage-point-event in the map represents a unique coverage-point to track. The integer it is mapped to is the number of times the coverage-point is visited. -
getTestAgentTrace
Return the "trace" of the specified test-agent. This trace is a chronologically ordered list of time-stamped events that this test-agent reported to this TestDataCollector. Note that verdicts count as time-stamped events. -
getTestAgentScalarsTrace
Return the trace of the specified agent, containing only of ScalarTracingEvents. -
getNumberOfFailVerdictsSeen
Get the number of negative verdicts reported by the specified test-agent. -
getNumberOfFailVerdictsSeen
public int getNumberOfFailVerdictsSeen()Get the total number of negative verdicts reported by all test-agents. -
getNumberOfPassVerdictsSeen
Get the number of positive verdicts reported by the specified test-agent. -
getNumberOfPassVerdictsSeen
public int getNumberOfPassVerdictsSeen()Get the total number of positive verdicts reported by all test-agents. -
getNumberOfUndecidedVerdictsSeen
Get the number of undecided verdicts reported by the specified test-agent. -
getNumberOfUndecidedVerdictsSeen
public int getNumberOfUndecidedVerdictsSeen()Get the total number of undecided verdicts reported by all test-agents. -
getLastFailVerdict
Get the last negative verdict reported by the specified test-agent. -
getLastFailVerdict
Get the last reported negative verdict. -
toString
-
parse
-
save
Save the data collected to files. Collected non-coverage events will be saved to the file fname (if it is not null). Coverage data are saved to covFname, if the latter is not null. Format of the events-file: For verdict-event: agent,time,"VerdictEvent",family,info,verdict For scalar-event: agent,time."ScalarTracingEvent",propname1,val1,propname2,val2,... Formal of coverage-file: coverage-point-name,num-of-total-visits,agent1,num-visit-by-agent1,agent2,...- Throws:
IOException
-
reset
public void reset()Reset the agents' traces recorded in this data-collector, and also reset all coverage information tracked by this data-collector (that means reseting their visit-counts to 0). -
merge
Merge two sets of collected test data. The merged data is put into a new instance of TestDataCollector.- Parameters:
data2
- test-date to merge with this test-data.
-
readCollectedTestData
Read collected test data from a file. -
saveTestAgentScalarsTraceAsCSV
public void saveTestAgentScalarsTraceAsCSV(String agentUniqueId, String filename) throws IOExceptionExport the scalar-trace of an agent to a CSV-file. ';' is used as the separator.- Throws:
IOException
-