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"));
}
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();
}
Aggregations