XCodeContext implements IXCodeContext { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((buildActions == null) ? 0 : buildActions.hashCode()); result = prime * result + ((options == null) ? 0 : options.hashCode()); result = prime * result + ((projectRootDirectory == null) ? 0 : projectRootDirectory.hashCode()); result = prime * result + ((settings == null) ? 0 : settings.hashCode()); return result; } XCodeContext(List<String> buildActions,
        File projectRootDirectory, PrintStream out, Settings settings, Options options); String getProjectName(); List<String> getBuildActions(); String getCodeSignIdentity(); File getProjectRootDirectory(); PrintStream getOut(); final void setOut(PrintStream out); @Override String getSDK(); @Override String getConfiguration(); String getProvisioningProfile(); String getTarget(); Options getOptions(); Settings getSettings(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testIsImmutable() throws Exception { Map<String, String> userOptions = new HashMap<String, String>(); 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(), "MyLibrary.xcodeproj"); Options options = new Options(userOptions, managedOptions); HashMap<String, String> userSettings = new HashMap<String, String>(); HashMap<String, String> managedSettings = new HashMap<String, String>(); managedSettings.put(Settings.ManagedSetting.CODE_SIGN_IDENTITY.name(), ""); Settings settings = new Settings(userSettings, managedSettings); List<String> buildActions = new ArrayList<String>(Arrays.asList("clean", "build")); File _projectDir = new File(projectDirectory.getParentFile().getCanonicalFile(), "MyLib2"); _projectDir.deleteOnExit(); FileUtils.copyDirectory(projectDirectory, _projectDir); final XCodeContext xCodeContext = new XCodeContext(buildActions, _projectDir, System.out, settings, options); int hashCode = xCodeContext.hashCode(); managedOptions.put("managedOptionAddedAfterwards", "xxxx"); managedSettings.put("managedSettigAddedAfterwards", "yyyy"); userOptions.put("userOptionAddedAfterwards", "1111"); userSettings.put("userSettigAddedAfterwards", "2222"); buildActions.add("addedAfterwards"); _projectDir.renameTo(new File(projectDirectory.getParent(), "MyLib3")); assertEquals("Context is not immutable.", hashCode, xCodeContext.hashCode()); }