Search in sources :

Example 1 with TmfXmlLocationCu

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);
}
Also used : Arrays(java.util.Arrays) TmfXmlStateValueCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateValueCu) Parameters(org.junit.runners.Parameterized.Parameters) TmfXmlTestUtils(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestUtils) DataDrivenValuePool(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValuePool) TmfXmlLocationCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlLocationCu) ImmutableList(com.google.common.collect.ImmutableList) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) DataDrivenStateSystemPath(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath) DataDrivenValueQuery(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueQuery) DataDrivenValueConstant(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueConstant) TmfXmlStrings(org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings) DataDrivenValue(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValue) IBaseQuarkProvider(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.IBaseQuarkProvider) DataDrivenValueEventName(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueEventName) ITmfStateValue(org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue) DataDrivenValueSelf(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueSelf) Assert.assertNotNull(org.junit.Assert.assertNotNull) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) DataDrivenValueEventField(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueEventField) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) TmfXmlStateValueCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateValueCu) Element(org.w3c.dom.Element) DataDrivenValue(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValue) TmfXmlLocationCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlLocationCu) DataDrivenValueEventField(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueEventField) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) DataDrivenValueConstant(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueConstant) Test(org.junit.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 AnalysisCompilationData (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData)1 TmfXmlLocationCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlLocationCu)1 TmfXmlStateValueCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateValueCu)1 DataDrivenStateSystemPath (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath)1 IBaseQuarkProvider (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.IBaseQuarkProvider)1 DataDrivenValue (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValue)1 DataDrivenValueConstant (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueConstant)1 DataDrivenValueEventField (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueEventField)1 DataDrivenValueEventName (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueEventName)1 DataDrivenValuePool (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValuePool)1 DataDrivenValueQuery (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueQuery)1 DataDrivenValueSelf (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueSelf)1 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)1