use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.
the class AnnotationDataLocationExtractorTest method empty_data_results_in_empty_string.
@Test
public void empty_data_results_in_empty_string() throws Exception {
/* prepare */
DocAnnotationData data = new DocAnnotationData();
/* execute */
String result = extractorToTest.extractLocation(data);
/* test */
assertEquals("", result);
}
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_value_documentation_found.
@Test
public void mustbedocumented_annotation_data_can_be_fetched_and_at_least_one_spring_value_documentation_found() {
ClasspathDataCollector collector = new ClasspathDataCollector();
List<DocAnnotationData> data = collector.fetchMustBeDocumentParts();
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 DocGenUtilTest method spring_scheduled__is_collected_by_build_method_and_set_to_data.
@Test
public void spring_scheduled__is_collected_by_build_method_and_set_to_data() throws Exception {
/* prepare */
AnnotatedElement element = mock(AnnotatedElement.class);
MustBeDocumented info = mock(MustBeDocumented.class);
Scheduled scheduled = mock(Scheduled.class);
when(scheduled.cron()).thenReturn("crondata");
when(element.getDeclaredAnnotation(Scheduled.class)).thenReturn(scheduled);
/* execute */
DocAnnotationData data = DocGeneratorUtil.buildDataForMustBeDocumented(info, element);
/* test */
assertEquals(scheduled, data.springScheduled);
}
use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.
the class KubernetesTemplateFilesGenerator method generateDeploymentFilePart.
private void generateDeploymentFilePart(KubernetesFiles result, List<DocAnnotationData> list) {
for (DocAnnotationData data : list) {
generateDeploymentCode(result, data);
}
String generatorName = getClass().getSimpleName();
StringBuilder all = new StringBuilder();
newLine(all, "# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #");
newLine(all, "# + Next kubernetes source is generated by: " + generatorName);
newLine(all, "# + when your code changes and you have new keys etc. please generate again and replace block ");
newLine(all, "# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #");
for (StringBuilder code : result.deploymentMap.values()) {
all.append(code);
}
newLine(all, "# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #");
newLine(all, "# + End of generated source from: " + getClass().getSimpleName());
newLine(all, "# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #");
result.serverDeploymentYaml = all.toString();
}
use of com.mercedesbenz.sechub.docgen.DocAnnotationData in project sechub by mercedes-benz.
the class ScheduleDescriptionGenerator 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 (data.springScheduled == null) {
continue;
}
SpringSchedule extracted = springScheduledExtractor.extract(data.springScheduled);
TableRow row = new TableRow();
row.scheduleType = extracted.getScheduleType().getText();
row.scheduleDefinition = extracted.getScheduleDefinition();
row.description = data.description;
row.location = locationExtractor.extractLocation(data);
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,6,6\"]\n");
sb.append(".").append(buildTitle(entries.getKey()));
sb.append("\n|===\n");
sb.append("|Type |Definition |Description\n");
sb.append("//----------------------\n");
for (TableRow row : table) {
sb.append("|").append(row.scheduleType);
sb.append("|").append(row.scheduleDefinition);
sb.append("|").append(row.description);
sb.append("\n");
}
sb.append("\n|===\n\n");
}
return sb.toString();
}
Aggregations