Program: 37597
Project: 37597
Buggy source:
@Test public void canCRUDSwapSlots() throws Exception {
  WebApp webApp=appServiceManager.webApps().define(WEBAPP_NAME).withRegion(Region.US_WEST).withNewResourceGroup(RG_NAME).withNewWindowsPlan(PricingTier.STANDARD_S2).withAppSetting("String_Node_Str","String_Node_Str").withStickyAppSetting("String_Node_Str","String_Node_Str").withConnectionString("String_Node_Str","String_Node_Str",ConnectionStringType.CUSTOM).withStickyConnectionString("String_Node_Str","String_Node_Str",ConnectionStringType.CUSTOM).withJavaVersion(JavaVersion.JAVA_1_7_0_51).withWebContainer(WebContainer.TOMCAT_7_0_50).create();
  Assert.assertNotNull(webApp);
  Assert.assertEquals(Region.US_WEST,webApp.region());
  DeploymentSlot slot1=webApp.deploymentSlots().define(SLOT_NAME_1).withBrandNewConfiguration().withPythonVersion(PythonVersion.PYTHON_27).create();
  Assert.assertNotNull(slot1);
  Assert.assertNotEquals(JavaVersion.JAVA_1_7_0_51,slot1.javaVersion());
  Assert.assertEquals(PythonVersion.PYTHON_27,slot1.pythonVersion());
  Map<String,AppSetting> appSettingMap=slot1.getAppSettings();
  Assert.assertFalse(appSettingMap.containsKey("String_Node_Str"));
  Assert.assertFalse(appSettingMap.containsKey("String_Node_Str"));
  Map<String,ConnectionString> connectionStringMap=slot1.getConnectionStrings();
  Assert.assertFalse(connectionStringMap.containsKey("String_Node_Str"));
  Assert.assertFalse(connectionStringMap.containsKey("String_Node_Str"));
  DeploymentSlot slot2=webApp.deploymentSlots().define(SLOT_NAME_2).withConfigurationFromParent().create();
  Assert.assertNotNull(slot2);
  Assert.assertEquals(JavaVersion.JAVA_1_7_0_51,slot2.javaVersion());
  appSettingMap=slot2.getAppSettings();
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  Assert.assertEquals(false,appSettingMap.get("String_Node_Str").sticky());
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  Assert.assertEquals(true,appSettingMap.get("String_Node_Str").sticky());
  connectionStringMap=slot2.getConnectionStrings();
  Assert.assertEquals("String_Node_Str",connectionStringMap.get("String_Node_Str").value());
  Assert.assertEquals(false,connectionStringMap.get("String_Node_Str").sticky());
  Assert.assertEquals("String_Node_Str",connectionStringMap.get("String_Node_Str").value());
  Assert.assertEquals(true,connectionStringMap.get("String_Node_Str").sticky());
  slot2.update().withoutJava().withPythonVersion(PythonVersion.PYTHON_34).withAppSetting("String_Node_Str","String_Node_Str").withStickyAppSetting("String_Node_Str","String_Node_Str").apply();
  Assert.assertNotNull(slot2);
  Assert.assertEquals(JavaVersion.OFF,slot2.javaVersion());
  Assert.assertEquals(PythonVersion.PYTHON_34,slot2.pythonVersion());
  appSettingMap=slot2.getAppSettings();
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  DeploymentSlot slot3=webApp.deploymentSlots().define(SLOT_NAME_3).withConfigurationFromDeploymentSlot(slot2).create();
  Assert.assertNotNull(slot3);
  Assert.assertEquals(JavaVersion.OFF,slot3.javaVersion());
  Assert.assertEquals(PythonVersion.PYTHON_34,slot3.pythonVersion());
  appSettingMap=slot3.getAppSettings();
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  DeploymentSlot deploymentSlot=webApp.deploymentSlots().getByName(SLOT_NAME_3);
  Assert.assertEquals(slot3.id(),deploymentSlot.id());
  List<DeploymentSlot> deploymentSlots=webApp.deploymentSlots().list();
  Assert.assertEquals(3,deploymentSlots.size());
  slot3.swap(slot1.name());
  slot1=webApp.deploymentSlots().getByName(SLOT_NAME_1);
  Assert.assertEquals(JavaVersion.OFF,slot1.javaVersion());
  Assert.assertEquals(PythonVersion.PYTHON_34,slot1.pythonVersion());
  Assert.assertEquals(PythonVersion.PYTHON_27,slot3.pythonVersion());
  Map<String,AppSetting> slot1AppSettings=slot1.getAppSettings();
  Map<String,AppSetting> slot3AppSettings=slot3.getAppSettings();
  Assert.assertEquals("String_Node_Str",slot1AppSettings.get("String_Node_Str").value());
  Assert.assertEquals("String_Node_Str",slot1AppSettings.get("String_Node_Str").value());
  Assert.assertEquals("String_Node_Str",slot3AppSettings.get("String_Node_Str").value());
  Assert.assertEquals("String_Node_Str",slot3AppSettings.get("String_Node_Str").value());
}

Fixed version (ground truth):
@Test public void canCRUDSwapSlots() throws Exception {
  WebApp webApp=appServiceManager.webApps().define(WEBAPP_NAME).withRegion(Region.US_WEST).withNewResourceGroup(RG_NAME).withNewWindowsPlan(PricingTier.STANDARD_S2).withAppSetting("String_Node_Str","String_Node_Str").withStickyAppSetting("String_Node_Str","String_Node_Str").withConnectionString("String_Node_Str","String_Node_Str",ConnectionStringType.CUSTOM).withStickyConnectionString("String_Node_Str","String_Node_Str",ConnectionStringType.CUSTOM).withJavaVersion(JavaVersion.JAVA_1_7_0_51).withWebContainer(WebContainer.TOMCAT_7_0_50).create();
  Assert.assertNotNull(webApp);
  Assert.assertEquals(Region.US_WEST,webApp.region());
  DeploymentSlot slot1=webApp.deploymentSlots().define(SLOT_NAME_1).withBrandNewConfiguration().withAppSetting("String_Node_Str","String_Node_Str").withStickyAppSetting("String_Node_Str","String_Node_Str").withConnectionString("String_Node_Str","String_Node_Str",ConnectionStringType.CUSTOM).withStickyConnectionString("String_Node_Str","String_Node_Str",ConnectionStringType.CUSTOM).withPythonVersion(PythonVersion.PYTHON_27).create();
  Assert.assertNotNull(slot1);
  Assert.assertNotEquals(JavaVersion.JAVA_1_7_0_51,slot1.javaVersion());
  Assert.assertEquals(PythonVersion.PYTHON_27,slot1.pythonVersion());
  Map<String,AppSetting> appSettingMap=slot1.getAppSettings();
  Assert.assertFalse(appSettingMap.containsKey("String_Node_Str"));
  Assert.assertFalse(appSettingMap.containsKey("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  Assert.assertFalse(appSettingMap.get("String_Node_Str").sticky());
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  Assert.assertTrue(appSettingMap.get("String_Node_Str").sticky());
  Map<String,ConnectionString> connectionStringMap=slot1.getConnectionStrings();
  Assert.assertFalse(connectionStringMap.containsKey("String_Node_Str"));
  Assert.assertFalse(connectionStringMap.containsKey("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",connectionStringMap.get("String_Node_Str").value());
  Assert.assertFalse(connectionStringMap.get("String_Node_Str").sticky());
  Assert.assertEquals("String_Node_Str",connectionStringMap.get("String_Node_Str").value());
  Assert.assertTrue(connectionStringMap.get("String_Node_Str").sticky());
  DeploymentSlot slot2=webApp.deploymentSlots().define(SLOT_NAME_2).withConfigurationFromParent().create();
  Assert.assertNotNull(slot2);
  Assert.assertEquals(JavaVersion.JAVA_1_7_0_51,slot2.javaVersion());
  appSettingMap=slot2.getAppSettings();
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  Assert.assertEquals(false,appSettingMap.get("String_Node_Str").sticky());
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  Assert.assertEquals(true,appSettingMap.get("String_Node_Str").sticky());
  connectionStringMap=slot2.getConnectionStrings();
  Assert.assertEquals("String_Node_Str",connectionStringMap.get("String_Node_Str").value());
  Assert.assertEquals(false,connectionStringMap.get("String_Node_Str").sticky());
  Assert.assertEquals("String_Node_Str",connectionStringMap.get("String_Node_Str").value());
  Assert.assertEquals(true,connectionStringMap.get("String_Node_Str").sticky());
  slot2.update().withoutJava().withPythonVersion(PythonVersion.PYTHON_34).withAppSetting("String_Node_Str","String_Node_Str").withStickyAppSetting("String_Node_Str","String_Node_Str").apply();
  Assert.assertNotNull(slot2);
  Assert.assertEquals(JavaVersion.OFF,slot2.javaVersion());
  Assert.assertEquals(PythonVersion.PYTHON_34,slot2.pythonVersion());
  appSettingMap=slot2.getAppSettings();
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  DeploymentSlot slot3=webApp.deploymentSlots().define(SLOT_NAME_3).withConfigurationFromDeploymentSlot(slot2).create();
  Assert.assertNotNull(slot3);
  Assert.assertEquals(JavaVersion.OFF,slot3.javaVersion());
  Assert.assertEquals(PythonVersion.PYTHON_34,slot3.pythonVersion());
  appSettingMap=slot3.getAppSettings();
  Assert.assertEquals("String_Node_Str",appSettingMap.get("String_Node_Str").value());
  DeploymentSlot deploymentSlot=webApp.deploymentSlots().getByName(SLOT_NAME_3);
  Assert.assertEquals(slot3.id(),deploymentSlot.id());
  List<DeploymentSlot> deploymentSlots=webApp.deploymentSlots().list();
  Assert.assertEquals(3,deploymentSlots.size());
  slot3.swap(slot1.name());
  slot1=webApp.deploymentSlots().getByName(SLOT_NAME_1);
  Assert.assertEquals(JavaVersion.OFF,slot1.javaVersion());
  Assert.assertEquals(PythonVersion.PYTHON_34,slot1.pythonVersion());
  Assert.assertEquals(PythonVersion.PYTHON_27,slot3.pythonVersion());
  Map<String,AppSetting> slot1AppSettings=slot1.getAppSettings();
  Map<String,AppSetting> slot3AppSettings=slot3.getAppSettings();
  Assert.assertEquals("String_Node_Str",slot1AppSettings.get("String_Node_Str").value());
  Assert.assertEquals("String_Node_Str",slot1AppSettings.get("String_Node_Str").value());
  Assert.assertEquals("String_Node_Str",slot3AppSettings.get("String_Node_Str").value());
  Assert.assertEquals("String_Node_Str",slot3AppSettings.get("String_Node_Str").value());
}