Search in sources :

Example 1 with LanguageElement

use of com.buschmais.jqassistant.core.report.api.model.LanguageElement in project jqa-core-framework by buschmais.

the class LanguageHelperTest method resolveName.

private void resolveName(TestDescriptorWithLanguageElement testDescriptor, LanguageElement expectedLanguageElement) {
    when(testDescriptor.getValue()).thenReturn("value");
    LanguageElement languageElement = LanguageHelper.getLanguageElement(testDescriptor);
    assertThat(languageElement, notNullValue());
    assertThat(languageElement, is(expectedLanguageElement));
    SourceProvider<TestDescriptorWithLanguageElement> sourceProvider = languageElement.getSourceProvider();
    String name = sourceProvider.getName(testDescriptor);
    assertThat(name, equalTo("value"));
}
Also used : DerivedTestDescriptorWithLanguageElement(com.buschmais.jqassistant.core.report.model.DerivedTestDescriptorWithLanguageElement) TestDescriptorWithLanguageElement(com.buschmais.jqassistant.core.report.model.TestDescriptorWithLanguageElement) DerivedTestDescriptorWithLanguageElement(com.buschmais.jqassistant.core.report.model.DerivedTestDescriptorWithLanguageElement) TestDescriptorWithLanguageElement(com.buschmais.jqassistant.core.report.model.TestDescriptorWithLanguageElement) LanguageElement(com.buschmais.jqassistant.core.report.api.model.LanguageElement) TestLanguageElement(com.buschmais.jqassistant.core.report.model.TestLanguage.TestLanguageElement)

Example 2 with LanguageElement

use of com.buschmais.jqassistant.core.report.api.model.LanguageElement in project jqa-core-framework by buschmais.

the class XmlReportPlugin method writeColumn.

/**
 * Determines the language and language element of a descriptor from a result
 * column.
 *
 * @param columnName
 *            The name of the column.
 * @param value
 *            The value.
 * @throws XMLStreamException
 *             If a problem occurs.
 */
private void writeColumn(String columnName, Object value) throws XMLStreamException {
    xmlStreamWriter.writeStartElement("column");
    xmlStreamWriter.writeAttribute("name", columnName);
    String label = null;
    if (value instanceof CompositeObject) {
        CompositeObject descriptor = (CompositeObject) value;
        LanguageElement elementValue = LanguageHelper.getLanguageElement(descriptor);
        if (elementValue != null) {
            xmlStreamWriter.writeStartElement("element");
            xmlStreamWriter.writeAttribute("language", elementValue.getLanguage());
            xmlStreamWriter.writeCharacters(elementValue.name());
            // element
            xmlStreamWriter.writeEndElement();
            SourceProvider sourceProvider = elementValue.getSourceProvider();
            label = sourceProvider.getName(descriptor);
            Optional<FileLocation> sourceLocation = sourceProvider.getSourceLocation(descriptor);
            if (sourceLocation.isPresent()) {
                xmlStreamWriter.writeStartElement("source");
                writeSourceLocation(sourceLocation.get());
                // sourceFile
                xmlStreamWriter.writeEndElement();
            }
        }
    } else if (value != null) {
        label = ReportHelper.getLabel(value);
    }
    writeElementWithCharacters("value", label);
    // column
    xmlStreamWriter.writeEndElement();
}
Also used : CompositeObject(com.buschmais.xo.api.CompositeObject) LanguageElement(com.buschmais.jqassistant.core.report.api.model.LanguageElement) FileLocation(com.buschmais.jqassistant.core.report.api.model.source.FileLocation)

Aggregations

LanguageElement (com.buschmais.jqassistant.core.report.api.model.LanguageElement)2 FileLocation (com.buschmais.jqassistant.core.report.api.model.source.FileLocation)1 DerivedTestDescriptorWithLanguageElement (com.buschmais.jqassistant.core.report.model.DerivedTestDescriptorWithLanguageElement)1 TestDescriptorWithLanguageElement (com.buschmais.jqassistant.core.report.model.TestDescriptorWithLanguageElement)1 TestLanguageElement (com.buschmais.jqassistant.core.report.model.TestLanguage.TestLanguageElement)1 CompositeObject (com.buschmais.xo.api.CompositeObject)1