public DeployTester build() {
            Clock clock = Optional.ofNullable(this.clock).orElseGet(Clock::systemUTC);
            Zone zone = Optional.ofNullable(this.zone).orElseGet(Zone::defaultZone);
            ConfigserverConfig configserverConfig = Optional.ofNullable(this.configserverConfig)
                    .orElseGet(() -> new ConfigserverConfig(new ConfigserverConfig.Builder()
                            .configServerDBDir(uncheck(() -> Files.createTempDirectory("serverdb")).toString())
                            .configDefinitionsDir(uncheck(() -> Files.createTempDirectory("configdefinitions")).toString())
                            .fileReferencesDir(uncheck(() -> Files.createTempDirectory("configdefinitions")).toString())));
            Provisioner provisioner = Optional.ofNullable(this.provisioner)
                    .orElseGet(() -> new MockProvisioner().hostProvisioner(createProvisioner()));
            List<ModelFactory> modelFactories = Optional.ofNullable(this.modelFactories)
                    .orElseGet(() -> List.of(createModelFactory(clock)));

            TestTenantRepository.Builder builder = new TestTenantRepository.Builder()
                    .withClock(clock)
                    .withConfigserverConfig(configserverConfig)
                    .withCurator(curator)
                    .withSecretStore(secretStore)
                    .withFileDistributionFactory(new MockFileDistributionFactory(configserverConfig))
                    .withMetrics(Optional.ofNullable(metrics).orElse(Metrics.createTestMetrics()))
                    .withModelFactoryRegistry((new ModelFactoryRegistry(modelFactories)))
                    .withZone(zone)
                    .withFlagSource(flagSource);

            if (configserverConfig.hostedVespa())
                builder.withHostProvisionerProvider(HostProvisionerProvider.withProvisioner(provisioner, configserverConfig));

            TenantRepository tenantRepository = builder.build();
            tenantRepository.addTenant(tenantName);

            ApplicationRepository applicationRepository = new ApplicationRepository.Builder()
                    .withTenantRepository(tenantRepository)
                    .withConfigserverConfig(configserverConfig)
                    .withOrchestrator(new OrchestratorMock())
                    .withClock(clock)
                    .withConfigConvergenceChecker(configConvergenceChecker)
                    .withFlagSource(flagSource)
                    .build();

            return new DeployTester(clock, tenantRepository, applicationRepository);
        }
Returns the number of models created successfully by this instance
configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java