use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier in project sechub by mercedes-benz.
the class UseCaseRestDocModelAsciiDocGenerator method generateAsciidoc.
// [options="header",cols="1,1,1"]
// |===
// |HeadA |HeadB |HeadC
// //----------------------
// |Row1A |Row1B |Row1C
// |Row2A |Row2B |Row2Cs
// |Row3A |Row3B |Row3C
// |===
public String generateAsciidoc(TextFileWriter writer, UseCaseRestDocModel model, boolean technical, UseCaseIdentifier... usecases) {
Objects.requireNonNull(writer);
Objects.requireNonNull(model);
Context context = new Context();
for (UseCaseIdentifier identifier : usecases) {
context.usecasesToInspect.add(identifier.name());
}
int h = 3;
context.addLine("[[section-ucrestdoc]]");
context.addLine(headline(h++) + "Rest API documentation");
context.addLine("");
context.addLine("ifdef::techdoc[]");
context.addLine("TIP: The complete documentation about REST API is generated. If you want to change content, please search for ");
context.addLine(" `@UseCaseRestDoc` references in source code and make necessary changes inside code!");
context.addLine("");
context.addLine("endif::techdoc[]");
List<List<UseCaseRestDocEntry>> found = generateOverview(model, context, h);
generateUseCaseAndRestDocDetails(context, h, found);
return context.getAsciiDoc();
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier in project sechub by mercedes-benz.
the class UseCaseEventOverviewPlantUmlGenerator method generateFile.
private void generateFile(File jsonSourceFile) {
String fileName = jsonSourceFile.getName();
if (!fileName.endsWith(".json")) {
if (DEBUG) {
LOG.info("ignoring filename:{}", fileName);
}
return;
} else {
if (DEBUG) {
LOG.info("inspect filename:{}", fileName);
}
}
String variant = filenameVariantconverter.getVariantFromFilename(fileName);
String originFileName = filenameVariantconverter.getFilenameWithoutVariant(fileName);
String usecaseId = originFileName.substring(0, originFileName.length() - 5);
/* .json = 5 chars */
UseCaseIdentifier usecaseIdentifier;
try {
usecaseIdentifier = UseCaseIdentifier.valueOf(usecaseId.toUpperCase());
} catch (RuntimeException e) {
LOG.error("File not a usecase:" + jsonSourceFile);
return;
}
LOG.info("Generate for usecase:{}, using json file: {}", usecaseIdentifier.name(), jsonSourceFile.getAbsolutePath());
if (jsonSourceFile.getAbsolutePath().endsWith("uc_admin_enables_scheduler_job_processing.json")) {
System.out.println("got");
}
String json = reader.loadTextFile(jsonSourceFile);
IntegrationTestEventHistory history = IntegrationTestEventHistory.fromJSONString(json);
try {
generate(history, usecaseIdentifier, variant);
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Wrong class names? Maybe you need to retrigger Integration tests to get new JSON files!", e);
} catch (IOException e) {
throw new IllegalStateException("Was not able to write file!", e);
}
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier in project sechub by mercedes-benz.
the class AsciidocGenerator method main.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new IllegalArgumentException("call with target gen folder as first parameter only!");
}
output(">AsciidocGenerator starting");
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
// avoid waringings from
root.setLevel(Level.INFO);
Logger reflections = (Logger) LoggerFactory.getLogger("org.reflections");
reflections.setLevel(Level.ERROR);
String path = args[0];
File documentsGenFolder = new File(path);
File documentsFolder = documentsGenFolder.getParentFile();
File diagramsFolder = new File(documentsFolder.getParentFile(), "diagrams");
File diagramsGenFolder = new File(diagramsFolder, "gen");
File systemProperitesFile = createSystemProperyTargetFile(documentsGenFolder);
File pdsSystemProperitesFile = createPDSSystemProperyTargetFile(documentsGenFolder);
File javaLaunchExampleFile = createJavaLaunchExampleTargetFile(documentsGenFolder);
File scheduleDescriptionFile = createScheduleDescriptionTargetFile(documentsGenFolder);
File specialMockValuePropertiesFile = createSpecialMockConfigurationPropertiesTargetFile(documentsGenFolder);
File messagingFile = createMessagingTargetFile(documentsGenFolder);
/* ---------------------- */
/* --- PRE-generation --- */
/* ---------------------- */
File jsonEventDataFolder = new File("./../sechub-integrationtest/build/test-results/event-trace");
UseCaseEventOverviewPlantUmlGenerator usecaseEventOverviewGenerator = new UseCaseEventOverviewPlantUmlGenerator(jsonEventDataFolder, diagramsGenFolder);
usecaseEventOverviewGenerator.generate();
Map<UseCaseIdentifier, Set<String>> useCasetoMessageIdsMap = usecaseEventOverviewGenerator.getUsecaseNameToMessageIdsMap();
UseCaseEventMessageLinkAsciidocGenerator useCaseEventMessageLinkAsciidocGenerator = new UseCaseEventMessageLinkAsciidocGenerator(useCasetoMessageIdsMap, documentsGenFolder);
useCaseEventMessageLinkAsciidocGenerator.generate();
/* ----------------------- */
/* --- Main-generation --- */
/* ----------------------- */
AsciidocGenerator generator = new AsciidocGenerator();
/* SECHUB */
generator.generateExampleFiles(documentsGenFolder);
generator.generateClientParts(documentsGenFolder);
generator.fetchMustBeDocumentParts();
generator.generateSystemPropertiesDescription(systemProperitesFile);
generator.generateJavaLaunchExample(javaLaunchExampleFile);
generator.generateScheduleDescription(scheduleDescriptionFile);
generator.generateMockPropertiesDescription(specialMockValuePropertiesFile);
generator.generateMessagingFiles(messagingFile, diagramsGenFolder);
generator.generateUseCaseFiles(documentsGenFolder, diagramsGenFolder);
generator.generateProfilesOverview(diagramsGenFolder);
/* PDS */
generator.generatePDSUseCaseFiles(documentsGenFolder, diagramsGenFolder);
generator.generatePDSSystemPropertiesDescription(pdsSystemProperitesFile);
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier in project sechub by mercedes-benz.
the class UseCaseEventMessageLinkAsciidocGenerator method generateLinkMessageToUsecasesContent.
private AsciidocBuilder generateLinkMessageToUsecasesContent(MessageID identifier) {
AsciidocBuilder ab = new AsciidocBuilder();
Set<UseCaseIdentifier> useCaseIdentifiers = filterRelatedUseCases(identifier);
if (useCaseIdentifiers == null || useCaseIdentifiers.isEmpty()) {
ab.add("// no usecases for message id:" + identifier);
return ab;
}
ab.add("[NOTE]");
ab.add("====");
ab.add("Use cases related to this message\n");
for (UseCaseIdentifier useCaseIdentifier : useCaseIdentifiers) {
String useCaseTitle = createTitle(useCaseIdentifier);
ab.add("- " + UseCaseAsciiDocFactory.createLinkToUseCase(useCaseIdentifier, useCaseTitle));
}
ab.add("====");
return ab;
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier in project sechub by mercedes-benz.
the class UseCaseModel method fetchId.
private UseCaseId fetchId(Class<? extends Annotation> clazz) {
UseCaseId r = new UseCaseId();
Class<? extends Annotation> clazzToFetch = DocReflectionUtil.resolveUnproxiedClass(clazz);
UseCaseDefinition definition = clazzToFetch.getAnnotation(UseCaseDefinition.class);
if (definition != null) {
UseCaseIdentifier ide = definition.id();
r.name = ide.name();
r.uniqueId = ide.uniqueId();
return r;
}
PDSUseCaseDefinition definition2 = clazzToFetch.getAnnotation(PDSUseCaseDefinition.class);
if (definition2 == null) {
throw new IllegalStateException("cannot fetch id from " + clazz);
}
PDSUseCaseIdentifier ide = definition2.id();
r.name = ide.name();
r.uniqueId = ide.uniqueId();
return r;
}
Aggregations