use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlLocationCu in project tracecompass by tracecompass.
the class TmfXmlStateAttributeAndLocationCuTest method testValidLocationCompilation.
/**
* Test the compilation of a valid state location strings, and states
* attributes that use it
*
* @throws SAXException
* Exception thrown by parser
* @throws IOException
* Exception thrown by parser
* @throws ParserConfigurationException
* Exception thrown by parser
*/
@Test
public void testValidLocationCompilation() throws SAXException, IOException, ParserConfigurationException {
String locName = "loc";
String location = "<location id=\"" + locName + "\">" + "<stateAttribute type=\"constant\" value=\"abc\" />" + "<stateAttribute type=\"eventField\" value=\"myField\" />" + "</location>";
AnalysisCompilationData data = new AnalysisCompilationData();
Element xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.LOCATION, location);
assertNotNull(xmlElement);
TmfXmlLocationCu locationCu = TmfXmlLocationCu.compile(data, xmlElement);
assertNotNull("location", locationCu);
// Add the location to the compilation data
data.addLocation(locName, locationCu);
// Compile a location state attribute
String attributeXml = "<stateAttribute type=\"location\" value=\"" + locName + "\" />";
xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.STATE_ATTRIBUTE, attributeXml);
assertNotNull(xmlElement);
List<@NonNull TmfXmlStateValueCu> attribute = TmfXmlStateValueCu.compileAttribute(data, xmlElement);
assertNotNull("Location attribute compilation", attribute);
assertEquals("Attribute count", 2, attribute.size());
List<DataDrivenValue> expected = ImmutableList.of(new DataDrivenValueConstant(null, ITmfStateValue.Type.NULL, "abc"), new DataDrivenValueEventField(null, ITmfStateValue.Type.NULL, "myField"));
List<DataDrivenValue> actual = attribute.stream().map(a -> a.generate()).collect(Collectors.toList());
assertEquals("Location generated", expected, actual);
}
Aggregations