Search in sources :

Example 1 with TestDescriptorWithLanguageElement

use of com.buschmais.jqassistant.core.report.model.TestDescriptorWithLanguageElement 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 TestDescriptorWithLanguageElement

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

the class LanguageHelperTest method resolveNameFromDescriptorWithLanguageElement.

@Test
public void resolveNameFromDescriptorWithLanguageElement() {
    TestDescriptorWithLanguageElement testDescriptor = Mockito.mock(TestDescriptorWithLanguageElement.class);
    resolveName(testDescriptor, TestLanguageElement.TestElement);
}
Also used : DerivedTestDescriptorWithLanguageElement(com.buschmais.jqassistant.core.report.model.DerivedTestDescriptorWithLanguageElement) TestDescriptorWithLanguageElement(com.buschmais.jqassistant.core.report.model.TestDescriptorWithLanguageElement) Test(org.junit.jupiter.api.Test)

Example 3 with TestDescriptorWithLanguageElement

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

the class ReportHelperTest method label.

@Test
void label() {
    TestDescriptorWithLanguageElement descriptorWithLabel = mock(TestDescriptorWithLanguageElement.class);
    when(descriptorWithLabel.getValue()).thenReturn("value");
    assertThat(ReportHelper.getLabel(descriptorWithLabel), equalTo("value"));
    assertThat(ReportHelper.getLabel(singletonList(descriptorWithLabel)), equalTo("value"));
    assertThat(ReportHelper.getLabel(new String[] { "value1", "value2" }), equalTo("value1, value2"));
    Map<String, Object> singleProperty = new HashMap<>();
    singleProperty.put("key", "Value");
    assertThat(ReportHelper.getLabel(singleProperty), equalTo("Value"));
    Map<String, Object> multipleProperties = new HashMap<>();
    multipleProperties.put("key1", descriptorWithLabel);
    multipleProperties.put("key2", "simpleValue");
    assertThat(ReportHelper.getLabel(multipleProperties), equalTo("key1:value, key2:simpleValue"));
    TestDescriptorWithLanguageElement descriptorWithEmptyLanguageLabel = mock(TestDescriptorWithLanguageElement.class);
    assertThat(ReportHelper.getLabel(descriptorWithEmptyLanguageLabel), notNullValue());
    // Composite object without supported label
    Neo4jNode neo4jNode = mock(Neo4jNode.class);
    doReturn(multipleProperties).when(neo4jNode).getProperties();
    CompositeObject compositeObject = mock(CompositeObject.class);
    doReturn(neo4jNode).when(compositeObject).getDelegate();
    assertThat(ReportHelper.getLabel(compositeObject), equalTo("key1:value, key2:simpleValue"));
}
Also used : TestDescriptorWithLanguageElement(com.buschmais.jqassistant.core.report.model.TestDescriptorWithLanguageElement) CompositeObject(com.buschmais.xo.api.CompositeObject) CompositeObject(com.buschmais.xo.api.CompositeObject) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Neo4jNode(com.buschmais.xo.neo4j.api.model.Neo4jNode) Test(org.junit.jupiter.api.Test)

Example 4 with TestDescriptorWithLanguageElement

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

the class XmlReportTestHelper method createRow.

private static Map<String, Object> createRow() {
    Map<String, Object> row = new HashMap<>();
    row.put(C1, "simpleValue");
    row.put(C2, new TestDescriptorWithLanguageElement() {

        @Override
        public <I> I getId() {
            return null;
        }

        @Override
        public <T> T as(Class<T> type) {
            return null;
        }

        @Override
        public <D> D getDelegate() {
            return null;
        }

        @Override
        public String getValue() {
            return "descriptorValue";
        }
    });
    return row;
}
Also used : TestDescriptorWithLanguageElement(com.buschmais.jqassistant.core.report.model.TestDescriptorWithLanguageElement) HashMap(java.util.HashMap)

Aggregations

TestDescriptorWithLanguageElement (com.buschmais.jqassistant.core.report.model.TestDescriptorWithLanguageElement)4 DerivedTestDescriptorWithLanguageElement (com.buschmais.jqassistant.core.report.model.DerivedTestDescriptorWithLanguageElement)2 Test (org.junit.jupiter.api.Test)2 LanguageElement (com.buschmais.jqassistant.core.report.api.model.LanguageElement)1 TestLanguageElement (com.buschmais.jqassistant.core.report.model.TestLanguage.TestLanguageElement)1 CompositeObject (com.buschmais.xo.api.CompositeObject)1 Neo4jNode (com.buschmais.xo.neo4j.api.model.Neo4jNode)1 HashMap (java.util.HashMap)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1