Profiles { public static OptionsByType getProfiles() { final String ORACLE_TOOLS_PROFILE = "bedrock.profile."; OptionsByType profiles = OptionsByType.empty(); for (String name : System.getProperties().stringPropertyNames()) { if (name.startsWith(ORACLE_TOOLS_PROFILE)) { String profileName = name.substring(ORACLE_TOOLS_PROFILE.length()).trim().toLowerCase(); String profileValue = System.getProperty(name); if (profileName.indexOf(".") < 0) { String profileClassName = "com.oracle.bedrock." + profileName + "." + profileName.substring(0, 1).toUpperCase() + profileName.substring(1) + "Profile"; try { Class<?> profileClass = Class.forName(profileClassName); if (Option.class.isAssignableFrom(profileClass)) { Profile profile = (Profile) profiles.get((Class<Option>) profileClass, profileValue); } else { } } catch (Exception e) { } } } } return profiles; }  static OptionsByType getProfiles();  }
@Test public void shouldReturnCreateProfiles() { System.setProperty("bedrock.profile.example", "hello"); OptionsByType optionsByType = Profiles.getProfiles(); assertThat(optionsByType, is(not(nullValue()))); assertThat(optionsByType.asArray().length, is(1)); ExampleProfile profile = optionsByType.get(ExampleProfile.class); assertThat(profile, is(not(nullValue()))); assertThat(profile.getParameters(), is("hello")); System.getProperties().remove("bedrock.profile.example"); }