001package ca.cdr.test.app.harness.api; 002 003import jakarta.annotation.Nullable; 004 005/** 006 * Record class that holds configuration information for connecting to a Smile CDR instance. 007 * This context can be used by {@link SmileHarness} implementations to establish connections to the CDR. 008 * 009 * @param protocol The connection protocol. Values are `http` or `https` 010 * @param baseUrl The base URL of the Smile CDR instance, e.g. `127.0.0.1` or `localhost` 011 * @param jsonAdminPort The port number for the administrative JSON API. If null, will attempt to auto-discover based on the properties file. 012 * @param username The username for authentication 013 * @param password The password for authentication 014 */ 015public record HarnessContext( 016 String protocol, 017 String baseUrl, 018 @Nullable Integer jsonAdminPort, 019 String username, 020 String password 021) { 022 023 /** 024 * Factory method that creates a default HarnessContext for connecting to a local Smile CDR instance. 025 * This method provides predefined values for a standard out-of-box-experience (OOBE) setup. If you haven't provided a custom properties file, 026 * this harness context should be used. If you have customized users/endpoints, you should build your own HarnessContext. 027 * 028 * @return A HarnessContext configured with default values for localhost connection 029 */ 030 public static HarnessContext oobeHarnessContext() { 031 return new HarnessContext( 032 "http", 033 "localhost", 034 null, 035 "admin", 036 "password" 037 ); 038 } 039 040 public String getContextRoot() { 041 return protocol + "://" + baseUrl; 042 } 043}