Search in sources :

Example 16 with DocAnnotationData

use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.

the class SystemPropertiesDescriptionGenerator method generate.

public String generate(List<DocAnnotationData> list, SpringValueFilter filter) {
    if (list == null || list.isEmpty()) {
        return "";
    }
    StringBuilder sb = new StringBuilder();
    Map<String, SortedSet<TableRow>> rowMap = new TreeMap<>();
    for (DocAnnotationData data : list) {
        if (SimpleStringUtils.isEmpty(data.springValue)) {
            continue;
        }
        SpringValue extracted = springValueExtractor.extract(data.springValue);
        if (filter.isFiltered(extracted)) {
            continue;
        }
        TableRow row = new TableRow();
        row.defaultValue = extracted.getDefaultValue();
        row.hasDefaultValue = extracted.hasDefaultValue();
        row.propertyKey = extracted.getKey();
        row.description = data.description;
        SortedSet<TableRow> rows = rowMap.get(data.scope);
        if (rows == null) {
            rows = new TreeSet<>();
            rowMap.put(data.scope, rows);
        }
        rows.add(row);
    }
    if (rowMap.isEmpty()) {
        return "";
    }
    appendStringContent(sb, rowMap);
    return sb.toString();
}
Also used : SpringValue(com.mercedesbenz.sechub.docgen.spring.SpringValueExtractor.SpringValue) DocAnnotationData(com.mercedesbenz.sechub.docgen.DocAnnotationData) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet)

Example 17 with DocAnnotationData

use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.

the class DocGeneratorUtil method buildDataForMustBeDocumented.

public static DocAnnotationData buildDataForMustBeDocumented(MustBeDocumented info, AnnotatedElement element) {
    DocAnnotationData data = new DocAnnotationData();
    data.scope = info.scope();
    data.isSecret = info.secret();
    data.description = info.value();
    buildSpringValueParts(data, element);
    buildSpringScheduledParts(data, element);
    /* when class name shall be used... */
    if (MustBeDocumented.SCOPE_USE_DEFINED_CLASSNAME_LOWERCASED.equals(data.scope)) {
        data.scope = toCamelOne(fetchClass(element)).toLowerCase();
    }
    return data;
}
Also used : DocAnnotationData(com.mercedesbenz.sechub.docgen.DocAnnotationData)

Example 18 with DocAnnotationData

use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.

the class DocGeneratorUtil method buildDataForPDSMustBeDocumented.

public static DocAnnotationData buildDataForPDSMustBeDocumented(PDSMustBeDocumented info, AnnotatedElement element) {
    DocAnnotationData data = new DocAnnotationData();
    data.scope = info.scope();
    data.isSecret = info.secret();
    data.description = info.value();
    buildSpringValueParts(data, element);
    buildSpringScheduledParts(data, element);
    /* when class name shall be used... */
    if (MustBeDocumented.SCOPE_USE_DEFINED_CLASSNAME_LOWERCASED.equals(data.scope)) {
        data.scope = toCamelOne(fetchClass(element)).toLowerCase();
    }
    return data;
}
Also used : DocAnnotationData(com.mercedesbenz.sechub.docgen.DocAnnotationData)

Example 19 with DocAnnotationData

use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.

the class DocGeneratorUtil method buildDataBy.

public static DocAnnotationData buildDataBy(Value info, AnnotatedElement element) {
    DocAnnotationData data = new DocAnnotationData();
    buildSpringValueParts(data, element);
    buildSpringScheduledParts(data, element);
    data.description = "See " + fetchClass(element).getSimpleName() + ".java";
    data.scope = toCamelOne(fetchClass(element)).toLowerCase();
    return data;
}
Also used : DocAnnotationData(com.mercedesbenz.sechub.docgen.DocAnnotationData)

Example 20 with DocAnnotationData

use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.

the class ScheduleDescriptionGeneratorTest method when_collector_returns_one_entry_with_spring_scheduled_fixedDelayString_a_table_is_build.

@Test
public void when_collector_returns_one_entry_with_spring_scheduled_fixedDelayString_a_table_is_build() throws Exception {
    /* prepare */
    DocAnnotationData a = new DocAnnotationData();
    a.springScheduled = mock(Scheduled.class);
    when(a.springScheduled.fixedDelayString()).thenReturn("fixedDelayString");
    List<DocAnnotationData> list = new ArrayList<>();
    list.add(a);
    when(collector.fetchMustBeDocumentParts()).thenReturn(list);
    /* execute */
    String generated = generatorToTest.generate(collector);
    /* test */
    assertNotNull(generated);
    assertFalse(generated.isEmpty());
    assertTrue(generated.indexOf("|===") != -1);
}
Also used : Scheduled(org.springframework.scheduling.annotation.Scheduled) ArrayList(java.util.ArrayList) DocAnnotationData(com.mercedesbenz.sechub.docgen.DocAnnotationData) Test(org.junit.Test)

Aggregations

DocAnnotationData (com.mercedesbenz.sechub.docgen.DocAnnotationData)24 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)7 Scheduled (org.springframework.scheduling.annotation.Scheduled)4 SortedSet (java.util.SortedSet)3 TreeMap (java.util.TreeMap)3 SpringValue (com.mercedesbenz.sechub.docgen.spring.SpringValueExtractor.SpringValue)2 Map (java.util.Map)2 SpringSchedule (com.mercedesbenz.sechub.docgen.spring.SpringScheduleExtractor.SpringSchedule)1 MustBeDocumented (com.mercedesbenz.sechub.sharedkernel.MustBeDocumented)1 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Value (org.springframework.beans.factory.annotation.Value)1