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