// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model;

import com.yahoo.component.Version;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.config.application.api.FileRegistry;
import com.yahoo.config.model.api.ConfigDefinitionRepo;
import com.yahoo.config.model.api.ConfigServerSpec;
import com.yahoo.config.model.api.HostProvisioner;
import com.yahoo.config.model.api.Model;
import com.yahoo.config.model.api.ModelContext;
import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.config.model.application.provider.MockFileRegistry;
import com.yahoo.config.model.application.provider.StaticConfigDefinitionRepo;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.Rotation;
import com.yahoo.config.provision.Zone;

import java.net.URI;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

/**
* @author hmusum
*/
public class MockModelContext implements ModelContext {

    private final ApplicationPackage applicationPackage;

    public MockModelContext() {
        this.applicationPackage = MockApplicationPackage.createEmpty();
    }

    public MockModelContext(ApplicationPackage applicationPackage) {
        this.applicationPackage = applicationPackage;
    }

    @Override
    public ApplicationPackage applicationPackage() {
        return applicationPackage;
    }

    @Override
    public Optional<Model> previousModel() {
        return Optional.empty();
    }

    @Override
    public Optional<ApplicationPackage> permanentApplicationPackage() {
        return Optional.empty();
    }

    @Override
    public Optional<HostProvisioner> hostProvisioner() {
        return Optional.empty();
    }

    @Override
    public DeployLogger deployLogger() {
        return new BaseDeployLogger();
    }

    @Override
    public ConfigDefinitionRepo configDefinitionRepo() {
        return new StaticConfigDefinitionRepo();
    }

    @Override
    public FileRegistry getFileRegistry() {
        return new MockFileRegistry();
    }

    @Override
    public Version modelVespaVersion() { return new Version(6); }

    @Override
    public Version wantedNodeVespaVersion() { return new Version(6); }

    @Override
    public Properties properties() {
        return new Properties() {
            @Override
            public boolean multitenant() {
                return false;
            }

            @Override
            public ApplicationId applicationId() {
                return ApplicationId.defaultId();
            }

            @Override
            public List<ConfigServerSpec> configServerSpecs() {
                return Collections.emptyList();
            }

            @Override
            public HostName loadBalancerName() {
                return null;
            }

            @Override
            public URI ztsUrl() {
                return null;
            }

            @Override
            public String athenzDnsSuffix() {
                return null;
            }

            @Override
            public boolean hostedVespa() {return false; }

            @Override
            public Zone zone() {
                return Zone.defaultZone();
            }

            @Override
            public Set<Rotation> rotations() {
                return new HashSet<>();
            }

            @Override
            public boolean isBootstrap() { return false; }

            @Override
            public boolean isFirstTimeDeployment() { return false; }

            @Override
            public boolean useDedicatedNodeForLogserver() { return false; }

            @Override
            public boolean useFdispatchByDefault() { return true; }

            @Override
            public boolean useAdaptiveDispatch() { return false; }
        };
    }
}

@@ -409,60 +409,8 @@
 po;%0A
-import com.yahoo.config.model.api.ConfigServerSpec;%0A
 impo
@@ -754,32 +754,85 @@
 DefinitionRepo;%0A
+import com.yahoo.config.model.deploy.TestProperties;%0A
 import com.yahoo
@@ -878,285 +878,8 @@
 ge;%0A
-import com.yahoo.config.provision.ApplicationId;%0Aimport com.yahoo.config.provision.HostName;%0Aimport com.yahoo.config.provision.Rotation;%0Aimport com.yahoo.config.provision.Zone;%0A%0Aimport java.net.URI;%0Aimport java.util.Collections;%0Aimport java.util.HashSet;%0Aimport java.util.List;
 %0Aimp
@@ -905,30 +905,8 @@
 nal;
-%0Aimport java.util.Set;
 %0A%0A/*
@@ -2297,16 +2297,20 @@
 urn new 
+Test
 Properti
@@ -2317,1515 +2317,8 @@
 es()
- %7B%0A            @Override%0A            public boolean multitenant() %7B%0A                return false;%0A            %7D%0A%0A            @Override%0A            public ApplicationId applicationId() %7B%0A                return ApplicationId.defaultId();%0A            %7D%0A%0A            @Override%0A            public List%3CConfigServerSpec%3E configServerSpecs() %7B%0A                return Collections.emptyList();%0A            %7D%0A%0A            @Override%0A            public HostName loadBalancerName() %7B%0A                return null;%0A            %7D%0A%0A            @Override%0A            public URI ztsUrl() %7B%0A                return null;%0A            %7D%0A%0A            @Override%0A            public String athenzDnsSuffix() %7B%0A                return null;%0A            %7D%0A%0A            @Override%0A            public boolean hostedVespa() %7Breturn false; %7D%0A%0A            @Override%0A            public Zone zone() %7B%0A                return Zone.defaultZone();%0A            %7D%0A%0A            @Override%0A            public Set%3CRotation%3E rotations() %7B%0A                return new HashSet%3C%3E();%0A            %7D%0A%0A            @Override%0A            public boolean isBootstrap() %7B return false; %7D%0A%0A            @Override%0A            public boolean isFirstTimeDeployment() %7B return false; %7D%0A%0A            @Override%0A            public boolean useDedicatedNodeForLogserver() %7B return false; %7D%0A%0A            @Override%0A            public boolean useFdispatchByDefault() %7B return true; %7D%0A%0A            @Override%0A            public boolean useAdaptiveDispatch() %7B return false; %7D%0A        %7D
 ;%0A  

Use TestProperties.