### Question:
HttpProtocolGeneratorUtils { static void writeHostPrefix(GenerationContext context, OperationShape operation) { TypeScriptWriter writer = context.getWriter(); SymbolProvider symbolProvider = context.getSymbolProvider(); EndpointTrait trait = operation.getTrait(EndpointTrait.class).get(); writer.write("let { hostname: resolvedHostname } = await context.endpoint();"); writer.openBlock("if (context.disableHostPrefix !== true) {", "}", () -> { writer.addImport("isValidHostname", "__isValidHostname", TypeScriptDependency.AWS_SDK_PROTOCOL_HTTP.packageName); writer.write("resolvedHostname = $S + resolvedHostname;", trait.getHostPrefix().toString()); List<SmithyPattern.Segment> prefixLabels = trait.getHostPrefix().getLabels(); StructureShape inputShape = context.getModel().expectShape(operation.getInput() .get(), StructureShape.class); for (SmithyPattern.Segment label : prefixLabels) { MemberShape member = inputShape.getMember(label.getContent()).get(); String memberName = symbolProvider.toMemberName(member); writer.openBlock("if (input.$L === undefined) {", "}", memberName, () -> { writer.write("throw new Error('Empty value provided for input host prefix: $L.');", memberName); }); writer.write("resolvedHostname = resolvedHostname.replace(\"{$L}\", input.$L!)", label.getContent(), memberName); } writer.openBlock("if (!__isValidHostname(resolvedHostname)) {", "}", () -> { writer.write("throw new Error(\"ValidationError: prefixed hostname must be hostname compatible.\");"); }); }); } private  HttpProtocolGeneratorUtils(); static String getTimestampInputParam(
            GenerationContext context,
            String dataSource,
            Shape shape,
            Format format
    ); static String getTimestampOutputParam(String dataSource, Location bindingType, Shape shape, Format format); static void writeRetryableTrait(TypeScriptWriter writer, StructureShape error, String separator);  }### Answer:
@Test public void writesCorrectHostPrefix() { GenerationContext mockContext = new GenerationContext(); mockContext.setSymbolProvider(new MockProvider()); TypeScriptWriter writer = new TypeScriptWriter("foo"); mockContext.setWriter(writer); Model model = Model.assembler() .addImport(getClass().getResource("endpoint-trait.smithy")) .assemble() .unwrap(); mockContext.setModel(model); OperationShape operation = (OperationShape) model.expectShape(ShapeId.from("smithy.example#GetFoo")); HttpProtocolGeneratorUtils.writeHostPrefix(mockContext, operation); assertThat(writer.toString(), containsString("let { hostname: resolvedHostname } = await context.endpoint();")); assertThat(writer.toString(), containsString("if (context.disableHostPrefix !== true) {")); assertThat(writer.toString(), containsString("resolvedHostname = \"{foo}.data.\" + resolvedHostname;")); assertThat(writer.toString(), containsString("resolvedHostname = resolvedHostname.replace(\"{foo}\", input.foo!)")); assertThat(writer.toString(), containsString("if (!__isValidHostname(resolvedHostname)) {")); assertThat(writer.toString(), containsString( "throw new Error(\"ValidationError: prefixed hostname must be hostname compatible.")); }