use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.
the class ClasspathDataCollectorTest method mustbedocumented_annotation_data_can_be_fetched_and_at_least_one_spring_schedule_documentation_found.
@Test
public void mustbedocumented_annotation_data_can_be_fetched_and_at_least_one_spring_schedule_documentation_found() {
ClasspathDataCollector collector = new ClasspathDataCollector();
List<DocAnnotationData> data = collector.fetchMustBeDocumentParts();
assertNotNull(data);
assertFalse(data.isEmpty());
Iterator<DocAnnotationData> iterator = data.iterator();
boolean atLeastOneDescribedSpringScheduleFound = false;
while (iterator.hasNext()) {
DocAnnotationData d = iterator.next();
assertNotNull(d);
if (!atLeastOneDescribedSpringScheduleFound) {
if (d.springScheduled != null) {
if (d.description != null && !d.description.isEmpty()) {
atLeastOneDescribedSpringScheduleFound = true;
}
}
}
}
assertTrue(atLeastOneDescribedSpringScheduleFound);
}
use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.
the class ClasspathDataCollectorTest method mockconfiguration_annotation_data_can_be_fetched_and_at_least_one_spring_value_documentation_found.
@Test
public void mockconfiguration_annotation_data_can_be_fetched_and_at_least_one_spring_value_documentation_found() {
ClasspathDataCollector collector = new ClasspathDataCollector();
List<DocAnnotationData> data = collector.fetchMockAdapterSpringValueDocumentationParts();
assertNotNull(data);
assertFalse(data.isEmpty());
Iterator<DocAnnotationData> iterator = data.iterator();
boolean atLeastOneDescribedSpringValueFound = false;
while (iterator.hasNext()) {
DocAnnotationData d = iterator.next();
assertNotNull(d);
if (!atLeastOneDescribedSpringValueFound) {
if (d.springValue != null) {
if (d.description != null && !d.description.isEmpty()) {
atLeastOneDescribedSpringValueFound = true;
}
}
}
}
assertTrue(atLeastOneDescribedSpringValueFound);
}
use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.
the class MockPropertiesDescriptionGenerator method generate.
public String generate(ClasspathDataCollector collector) {
if (collector == null) {
return "";
}
List<DocAnnotationData> list = collector.fetchMustBeDocumentParts();
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);
TableRow row = new TableRow();
row.defaultValue = extracted.getDefaultValue();
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 "";
}
for (Map.Entry<String, SortedSet<TableRow>> entries : rowMap.entrySet()) {
SortedSet<TableRow> table = entries.getValue();
sb.append("[options=\"header\",cols=\"1,1,1\"]\n");
sb.append(".").append(buildTitle(entries.getKey()));
sb.append("\n|===\n");
sb.append("|Key |Default |Description \n");
sb.append("//----------------------\n");
for (TableRow row : table) {
sb.append("|").append(row.propertyKey);
sb.append("|").append(row.defaultValue);
sb.append("|").append(row.description);
sb.append("\n");
}
sb.append("\n|===\n\n");
}
return sb.toString();
}
use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.
the class MockedAdaptersSpringValueDataCollector method addClassOnly.
private void addClassOnly(Set<Class<?>> types, List<DocAnnotationData> list) {
for (Class<?> type : types) {
Set<Method> methods = buildMethods(type);
Set<Field> fields = buildFields(type);
/* handle class annotations */
Value info0 = type.getDeclaredAnnotation(Value.class);
if (info0 != null) {
DocAnnotationData data0 = DocGeneratorUtil.buildDataBy(info0, type);
data0.linkedClass = type;
list.add(data0);
}
/* handle method annotations */
for (Method method : methods) {
Value info1 = method.getDeclaredAnnotation(Value.class);
if (info1 == null) {
continue;
}
DocAnnotationData data1 = DocGeneratorUtil.buildDataBy(info1, method);
data1.linkedMethod = method;
list.add(data1);
}
/* handle field annotations */
for (Field field : fields) {
Value info2 = field.getDeclaredAnnotation(Value.class);
if (info2 == null) {
continue;
}
DocAnnotationData data2 = DocGeneratorUtil.buildDataBy(info2, field);
data2.linkedField = field;
list.add(data2);
}
}
}
use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.
the class KubernetesTemplateFilesGenerator method newAnnotationData.
private DocAnnotationData newAnnotationData(String springValue, String scope, String description, boolean secret, String secretFileName) {
DocAnnotationData data = new DocAnnotationData();
data.isSecret = secret;
data.description = description;
data.scope = scope;
data.springValue = springValue;
data.options.put(OPTION_SECRET_FILE_NAME, secretFileName);
return data;
}
Aggregations