@Test public void when_collector_returns_empty_list_result_is_not_null_but_empty() throws Exception { when(collector.fetchMustBeDocumentParts()).thenReturn(Collections.emptyList()); String generated = generatorToTest.generate(collector); assertNotNull(generated); assertTrue(generated.isEmpty()); }
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,1,1,1\"]\n"); sb.append(".").append(buildTitle(entries.getKey())); sb.append("\n|===\n"); sb.append("|Type |Definition |Description\n"); sb.append(" 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(); }
ScheduleDescriptionGenerator implements Generator { 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,1,1,1\"]\n"); sb.append(".").append(buildTitle(entries.getKey())); sb.append("\n|===\n"); sb.append("|Type |Definition |Description\n"); sb.append(" 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(); } }
ScheduleDescriptionGenerator implements Generator { 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,1,1,1\"]\n"); sb.append(".").append(buildTitle(entries.getKey())); sb.append("\n|===\n"); sb.append("|Type |Definition |Description\n"); sb.append(" 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(); } ScheduleDescriptionGenerator(); }
ScheduleDescriptionGenerator implements Generator { 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,1,1,1\"]\n"); sb.append(".").append(buildTitle(entries.getKey())); sb.append("\n|===\n"); sb.append("|Type |Definition |Description\n"); sb.append(" 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(); } ScheduleDescriptionGenerator(); String generate(ClasspathDataCollector collector); }
ScheduleDescriptionGenerator implements Generator { 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,1,1,1\"]\n"); sb.append(".").append(buildTitle(entries.getKey())); sb.append("\n|===\n"); sb.append("|Type |Definition |Description\n"); sb.append(" 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(); } ScheduleDescriptionGenerator(); String generate(ClasspathDataCollector collector);  }