CommandLineBuilder { String[] createBuildCall() { List<String> result = new ArrayList<String>(); result.add(XCODEBUILD); appendOptions(xcodeContext, result); for (String buildAction : xcodeContext.getBuildActions()) { appendValue(result, buildAction); } appendSettings(xcodeContext.getSettings(), result); return result.toArray(new String[result.size()]); } CommandLineBuilder(XCodeContext ctx); @Override String toString();  }
@Test public void testCodeSignIdentity() throws Exception { Map<String, String> userSettings = null, managedSettings = new HashMap<String, String>(); managedSettings.put("CODE_SIGN_IDENTITY", "MyCodeSignIdentity"); Settings settings = new Settings(userSettings, managedSettings); Map<String, String> managedOptions = new HashMap<String, String>(); managedOptions.put(Options.ManagedOption.CONFIGURATION.getOptionName(), "Release"); managedOptions.put(Options.ManagedOption.SDK.getOptionName(), "mysdk"); managedOptions.put(Options.ManagedOption.PROJECT.getOptionName(), "MyLib.xcodeproj"); Options options = new Options(null, managedOptions); XCodeContext context = new XCodeContext(Arrays.asList("clean", "build"), projectDirectory, System.out, settings, options); CommandLineBuilder commandLineBuilder = new CommandLineBuilder(context); assertTrue(Arrays.asList(commandLineBuilder.createBuildCall()).contains("CODE_SIGN_IDENTITY=MyCodeSignIdentity")); }
@Test public void testProvisioningProfile() throws Exception { Map<String, String> userSettings = null, managedSettings = new HashMap<String, String>(); managedSettings.put("PROVISIONING_PROFILE", "MyProvisioningProfile"); Settings settings = new Settings(userSettings, managedSettings); Map<String, String> managedOptions = new HashMap<String, String>(); managedOptions.put(Options.ManagedOption.CONFIGURATION.getOptionName(), "Release"); managedOptions.put(Options.ManagedOption.SDK.getOptionName(), "mysdk"); managedOptions.put(Options.ManagedOption.PROJECT.getOptionName(), "MyLib.xcodeproj"); Options options = new Options(null, managedOptions); XCodeContext context = new XCodeContext(Arrays.asList("clean", "build"), projectDirectory, System.out, settings, options); CommandLineBuilder commandLineBuilder = new CommandLineBuilder(context); assertTrue(Arrays.asList(commandLineBuilder.createBuildCall()).contains( "PROVISIONING_PROFILE=MyProvisioningProfile")); }
@Test public void testProvisioningProfileIsNull() throws Exception { Map<String, String> managedOptions = new HashMap<String, String>(); managedOptions.put(Options.ManagedOption.CONFIGURATION.getOptionName(), "Release"); managedOptions.put(Options.ManagedOption.SDK.getOptionName(), "mysdk"); managedOptions.put(Options.ManagedOption.PROJECT.getOptionName(), "MyLib.xcodeproj"); Options options = new Options(null, managedOptions); XCodeContext context = new XCodeContext(Arrays.asList("clean", "build"), projectDirectory, System.out, null, options); CommandLineBuilder commandLineBuilder = new CommandLineBuilder(context); for (String param : commandLineBuilder.createBuildCall()) { assertFalse("The command line must not contain a parameter 'PROVISIONING_PROFILE='", param.contains("PROVISIONING_PROFILE=")); } }