DeployState implements ConfigDefinitionStore { @Override public final Optional<ConfigDefinition> getConfigDefinition(ConfigDefinitionKey defKey) { if (existingConfigDefs == null) { existingConfigDefs = new LinkedHashMap<>(); configDefinitionRepo.ifPresent(definitionRepo -> existingConfigDefs.putAll(createLazyMapping(definitionRepo))); existingConfigDefs.putAll(applicationPackage.getAllExistingConfigDefs()); } if ( ! existingConfigDefs.containsKey(defKey)) return Optional.empty(); if (defArchive.get(defKey) != null) return Optional.of(defArchive.get(defKey)); ConfigDefinition def = existingConfigDefs.get(defKey).parse(); defArchive.put(defKey, def); return Optional.of(def); } private  DeployState(ApplicationPackage applicationPackage,
                        SearchDocumentModel searchDocumentModel,
                        RankProfileRegistry rankProfileRegistry,
                        FileRegistry fileRegistry,
                        DeployLogger deployLogger,
                        Optional<HostProvisioner> hostProvisioner,
                        Provisioned provisioned,
                        ModelContext.Properties properties,
                        Version vespaVersion,
                        Optional<ApplicationPackage> permanentApplicationPackage,
                        Optional<ConfigDefinitionRepo> configDefinitionRepo,
                        Optional<Model> previousModel,
                        Set<ContainerEndpoint> endpoints,
                        Collection<MlModelImporter> modelImporters,
                        Zone zone,
                        QueryProfiles queryProfiles,
                        SemanticRules semanticRules,
                        Instant now,
                        Version wantedNodeVespaVersion,
                        boolean accessLoggingEnabledByDefault,
                        Optional<DockerImage> wantedDockerImageRepo); static DeployState createTestState(); static DeployState createTestState(DeployLogger testLogger); static DeployState createTestState(ApplicationPackage applicationPackage); static HostProvisioner getDefaultModelHostProvisioner(ApplicationPackage applicationPackage); Provisioned provisioned(); final RankProfileRegistry rankProfileRegistry(); ValidationOverrides validationOverrides(); @Override final Optional<ConfigDefinition> getConfigDefinition(ConfigDefinitionKey defKey); ApplicationPackage getApplicationPackage(); List<NamedSchema> getSchemas(); DocumentModel getDocumentModel(); DeployLogger getDeployLogger(); boolean getAccessLoggingEnabledByDefault(); FileRegistry getFileRegistry(); HostProvisioner getProvisioner(); Optional<ApplicationPackage> getPermanentApplicationPackage(); ModelContext.Properties getProperties(); Version getVespaVersion(); Optional<Model> getPreviousModel(); boolean isHosted(); Set<ContainerEndpoint> getEndpoints(); Zone zone(); QueryProfiles getQueryProfiles(); SemanticRules getSemanticRules(); ImportedMlModels getImportedModels(); Version getWantedNodeVespaVersion(); Optional<DockerImage> getWantedDockerImageRepo(); Instant now(); Optional<EndpointCertificateSecrets> endpointCertificateSecrets(); Optional<String> tlsClientAuthority();  }
@Test public void testDefinitionRepoIsUsed() { Map<ConfigDefinitionKey, com.yahoo.vespa.config.buildergen.ConfigDefinition> defs = new LinkedHashMap<>(); defs.put(new ConfigDefinitionKey("foo", "bar"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("foo", new String[]{"namespace=bar", "foo int default=0"})); defs.put(new ConfigDefinitionKey("test2", "a.b"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("namespace-in-filename", new String[]{"namespace=a.b", "doubleVal double default=1.0"})); ApplicationPackage app = FilesApplicationPackage.fromFile(new File("src/test/cfg DeployState state = createDeployState(app, defs); assertNotNull(state.getConfigDefinition(new ConfigDefinitionKey("foo", "bar"))); ConfigDefinition overridden = state.getConfigDefinition(new ConfigDefinitionKey("namespace-in-filename", "a.b")).get(); assertNotNull(overridden); Double defaultValue = overridden.getDoubleDefs().get("doubleVal").getDefVal(); assertNotNull(defaultValue); assertThat(defaultValue.intValue(), is(0)); }
@Test public void testGetConfigDefinition() { Map<ConfigDefinitionKey, com.yahoo.vespa.config.buildergen.ConfigDefinition> defs = new LinkedHashMap<>(); defs.put(new ConfigDefinitionKey("test2", "a.b"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("test2", new String[]{"namespace=a.b", "doubleVal double default=1.0"})); defs.put(new ConfigDefinitionKey("test3", "xyzzy"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("test3", new String[]{"namespace=xyzzy", "message string"})); ApplicationPackage app = FilesApplicationPackage.fromFile(new File("src/test/cfg DeployState state = createDeployState(app, defs); assertNotNull(state.getConfigDefinition(new ConfigDefinitionKey("test2", "a.b"))); ConfigDefinition test1 = state.getConfigDefinition(new ConfigDefinitionKey("test2", "a.b")).get(); assertNotNull(test1); assertThat(test1.getName(), is("test2")); assertThat(test1.getNamespace(), is("a.b")); }