public void generateProtocolTests()

in codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/integration/HttpProtocolTestGenerator.java [95:179]


    public void generateProtocolTests() {
        OperationIndex operationIndex = model.getKnowledge(OperationIndex.class);
        TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);

        for (OperationShape operation : new TreeSet<>(topDownIndex.getContainedOperations(service))) {
            if (operation.hasTag("server-only")) {
                continue;
            }

            // 1. Generate test cases for each request.
            operation.getTrait(HttpRequestTestsTrait.class).ifPresent(trait -> {
                final List<HttpRequestTestCase> testCases = filterProtocolTestCases(trait.getTestCases());
                if (testCases.isEmpty()) {
                    return;
                }

                delegator.useShapeTestWriter(operation, (writer) -> {
                    LOGGER.fine(() -> format("Generating request protocol test case for %s", operation.getId()));
                    requestTestBuilder.model(model)
                            .symbolProvider(symbolProvider)
                            .protocolName(protocolName)
                            .service(service)
                            .operation(operation)
                            .testCases(trait.getTestCases())
                            .build()
                            .generateTestFunction(writer);
                });
            });

            // 2. Generate test cases for each response.
            operation.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
                final List<HttpResponseTestCase> testCases = filterProtocolTestCases(trait.getTestCases());
                if (testCases.isEmpty()) {
                    return;
                }

                delegator.useShapeTestWriter(operation, (writer) -> {
                    LOGGER.fine(() -> format("Generating response protocol test case for %s", operation.getId()));
                    responseTestBuilder.model(model)
                            .symbolProvider(symbolProvider)
                            .protocolName(protocolName)
                            .service(service)
                            .operation(operation)
                            .testCases(trait.getTestCases())
                            .shapeValueGeneratorConfig(ShapeValueGenerator.Config.builder()
                                    .normalizeHttpPrefixHeaderKeys(true).build())
                            .build()
                            .generateTestFunction(writer);
                });
            });

            // 3. Generate test cases for each error on each operation.
            for (StructureShape error : operationIndex.getErrors(operation)) {
                if (error.hasTag("server-only")) {
                    continue;
                }

                error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
                    final List<HttpResponseTestCase> testCases = filterProtocolTestCases(trait.getTestCases());
                    if (testCases.isEmpty()) {
                        return;
                    }

                    delegator.useShapeTestWriter(operation, (writer) -> {
                        LOGGER.fine(() -> format("Generating response error protocol test case for %s",
                                operation.getId()));
                        responseErrorTestBuilder.model(model)
                                .symbolProvider(symbolProvider)
                                .protocolName(protocolName)
                                .service(service)
                                .operation(operation)
                                .error(error)
                                .testCases(trait.getTestCases())
                                .build()
                                .generateTestFunction(writer);
                    });
                });
            }
        }

        // Include any additional stubs required.
        for (String additionalStub : additionalStubs) {
            writer.write(IoUtils.readUtf8Resource(getClass(), additionalStub));
        }
    }