public PrepareResult prepare(HostValidator hostValidator, DeployLogger logger, PrepareParams params,
                                 Optional<ApplicationVersions> activeApplicationVersions, Instant now, File serverDbSessionDir,
                                 ApplicationPackage applicationPackage, SessionZooKeeperClient sessionZooKeeperClient) {
        ApplicationId applicationId = params.getApplicationId();
        Preparation preparation = new Preparation(hostValidator, logger, params, activeApplicationVersions,
                                                  TenantRepository.getTenantPath(applicationId.tenant()),
                                                  serverDbSessionDir, applicationPackage, sessionZooKeeperClient,
                                                  onnxModelCost, endpointCertificateSecretStores);
        preparation.preprocess();
        try {
            AllocatedHosts allocatedHosts = preparation.buildModels(now);
            preparation.makeResult(allocatedHosts);
            if ( ! params.isDryRun()) {
                FileReference fileReference = preparation.triggerDistributionOfApplicationPackage();
                preparation.writeStateZK(fileReference);
                preparation.writeEndpointCertificateMetadataZK();
                preparation.writeContainerEndpointsZK();
            }
            log.log(Level.FINE, () -> "time used " + params.getTimeoutBudget().timesUsed() + " : " + applicationId);
            return preparation.result();
        }
        catch (IllegalArgumentException e) {
            if (e instanceof InvalidApplicationException)
                throw e;
            throw new InvalidApplicationException("Invalid application package", e);
        }
    }
@Test
    public void require_that_cloud_account_is_written() throws Exception {
        TestModelFactory modelFactory = new TestModelFactory(version123);
        preparer = createPreparer(new ModelFactoryRegistry(List.of(modelFactory)), HostProvisionerProvider.empty());
        ApplicationId applicationId = applicationId("test");
        CloudAccount expected = CloudAccount.from("012345678912");
        PrepareParams params = new PrepareParams.Builder().applicationId(applicationId)
                                                          .cloudAccount(expected)
                                                          .build();
        prepare(new File("src/test/resources/deploy/hosted-app"), params);

        SessionZooKeeperClient zkClient = createSessionZooKeeperClient();
        assertEquals(expected, zkClient.readCloudAccount().get());

        ModelContext modelContext = modelFactory.getModelContext();
        Optional<CloudAccount> accountFromModel = modelContext.properties().cloudAccount();
        assertEquals(Optional.of(expected), accountFromModel);
    }