Search in sources :

Example 1 with UseCaseIdentifier

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();
}
Also used : UseCaseIdentifier(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with UseCaseIdentifier

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);
    }
}
Also used : UseCaseIdentifier(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier) IntegrationTestEventHistory(com.mercedesbenz.sechub.sharedkernel.messaging.IntegrationTestEventHistory) IOException(java.io.IOException)

Example 3 with UseCaseIdentifier

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);
}
Also used : UseCaseIdentifier(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier) Set(java.util.Set) UseCaseEventMessageLinkAsciidocGenerator(com.mercedesbenz.sechub.docgen.messaging.UseCaseEventMessageLinkAsciidocGenerator) UseCaseEventMessageLinkAsciidocGenerator(com.mercedesbenz.sechub.docgen.messaging.UseCaseEventMessageLinkAsciidocGenerator) UseCaseEventOverviewPlantUmlGenerator(com.mercedesbenz.sechub.docgen.messaging.UseCaseEventOverviewPlantUmlGenerator) Logger(ch.qos.logback.classic.Logger) File(java.io.File)

Example 4 with UseCaseIdentifier

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;
}
Also used : UseCaseIdentifier(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier)

Example 5 with UseCaseIdentifier

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;
}
Also used : PDSUseCaseIdentifier(com.mercedesbenz.sechub.pds.usecase.PDSUseCaseIdentifier) UseCaseIdentifier(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier) PDSUseCaseIdentifier(com.mercedesbenz.sechub.pds.usecase.PDSUseCaseIdentifier) UseCaseDefinition(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseDefinition) PDSUseCaseDefinition(com.mercedesbenz.sechub.pds.usecase.PDSUseCaseDefinition) PDSUseCaseDefinition(com.mercedesbenz.sechub.pds.usecase.PDSUseCaseDefinition)

Aggregations

UseCaseIdentifier (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseIdentifier)7 File (java.io.File)3 Set (java.util.Set)3 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 Logger (ch.qos.logback.classic.Logger)1 UseCaseEventMessageLinkAsciidocGenerator (com.mercedesbenz.sechub.docgen.messaging.UseCaseEventMessageLinkAsciidocGenerator)1 UseCaseEventOverviewPlantUmlGenerator (com.mercedesbenz.sechub.docgen.messaging.UseCaseEventOverviewPlantUmlGenerator)1 PDSUseCaseDefinition (com.mercedesbenz.sechub.pds.usecase.PDSUseCaseDefinition)1 PDSUseCaseIdentifier (com.mercedesbenz.sechub.pds.usecase.PDSUseCaseIdentifier)1 IntegrationTestEventHistory (com.mercedesbenz.sechub.sharedkernel.messaging.IntegrationTestEventHistory)1 UseCaseDefinition (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseDefinition)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.jupiter.api.Test)1 EnabledIfSystemProperty (org.junit.jupiter.api.condition.EnabledIfSystemProperty)1