package savetheenvironment.profiles.mocking;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

public class Main {

    static AnnotationConfigApplicationContext runWithApplicationContext() {
        AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext();

        ac.getEnvironment().setActiveProfiles(ServiceConfiguration.PROFILE_VIDEO_YOUTUBE );

        ac.register(ServiceConfiguration.class);
        ac.refresh();
        return ac;
    }

    public static void main(String[] arrrImAPirate) throws Throwable {
        ApplicationContext applicationContext = runWithApplicationContext();
        VideoSearch videoSearch = applicationContext.getBean(VideoSearch.class);
        List<String> videoTitles = videoSearch.lookupVideo("Kevin Nilson");

        System.out.println();
        System.out.println("************** VIDEO SEARCH RESULTS - YOUTUBE ************** ");

        for (String title : videoTitles) {
            System.out.println(title);
        }
    }
}
@@ -176,16 +176,154 @@
 ontext;%0A
+import org.springframework.core.env.MapPropertySource;%0Aimport org.springframework.core.env.StandardEnvironment;%0A%0Aimport java.util.HashMap;
 %0Aimport 
@@ -337,16 +337,38 @@
 il.List;
+%0Aimport java.util.Map;
 %0A%0Apublic
@@ -637,17 +637,16 @@
 _YOUTUBE
- 
 );%0A%0A    
@@ -885,16 +885,1206 @@
 ntext();
+%0A%0A        showEnvironment(applicationContext);%0A%0A        showPropertySource(applicationContext);%0A%0A        showVideos(applicationContext);%0A    %7D%0A%0A    private static void showPropertySource(ApplicationContext applicationContext) %7B%0A%0A        System.out.println();%0A        System.out.println(%22************ Property Source ***********%22);%0A%0A        Map%3CString, Object%3E map = new HashMap%3CString, Object%3E();%0A        map.put(%22db_username%22, %22scott%22);%0A        map.put(%22db_password%22, %22tiger%22);%0A%0A%0A        MapPropertySource mapPropertySource = new MapPropertySource(%22dbConfig%22, map);%0A%0A        ((StandardEnvironment) applicationContext.getEnvironment()).getPropertySources().addFirst(mapPropertySource);%0A%0A        System.out.println(%22DB Username: %22 + applicationContext.getEnvironment().getProperty(%22db_username%22));%0A        System.out.println(%22DB Password: %22 + applicationContext.getEnvironment().getProperty(%22db_password%22));%0A%0A        System.out.println();%0A%0A        System.out.println(%22DB Url from @PropertySource: %22 + applicationContext.getEnvironment().getProperty(%22db.url%22));%0A%0A        System.out.println();%0A    %7D%0A%0A    private static void showVideos(ApplicationContext applicationContext) throws Exception %7B
 %0A       
@@ -2455,10 +2455,330 @@
  %7D%0A    %7D
+%0A%0A    private static void showEnvironment(ApplicationContext applicationContext) %7B%0A        System.out.println();%0A        System.out.println(%22************ Environment ***********%22);%0A        System.out.println(%22User Dir: %22 + applicationContext.getEnvironment().getProperty(%22user.dir%22));%0A        System.out.println();%0A    %7D
 %0A%7D

break down examples