Program: 37586
Project: 37586
Buggy source:
@Override public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) throws Exception {
  final Region region=Region.US_EAST;
  final String groupName="String_Node_Str" + this.testId;
  final String pipName="String_Node_Str" + this.testId;
  final String pipDnsLabel=SdkContext.randomResourceName("String_Node_Str",15);
  final String tmProfileName="String_Node_Str" + this.testId;
  final String nestedTmProfileName="String_Node_Str" + tmProfileName;
  final String tmProfileDnsLabel=SdkContext.randomResourceName("String_Node_Str",15);
  final String nestedTmProfileDnsLabel="String_Node_Str" + tmProfileDnsLabel;
  ResourceGroup.DefinitionStages.WithCreate rgCreatable=profiles.manager().resourceManager().resourceGroups().define(groupName).withRegion(region);
  TrafficManagerProfile nestedProfile=profiles.define(nestedTmProfileName).withNewResourceGroup(rgCreatable).withLeafDomainLabel(nestedTmProfileDnsLabel).withPriorityBasedRouting().defineExternalTargetEndpoint("String_Node_Str").toFqdn("String_Node_Str").fromRegion(Region.INDIA_CENTRAL).attach().withHttpsMonitoring().withTimeToLive(500).create();
  Assert.assertTrue(nestedProfile.isEnabled());
  Assert.assertNotNull(nestedProfile.monitorStatus());
  Assert.assertEquals(nestedProfile.monitoringPort(),443);
  Assert.assertEquals(nestedProfile.monitoringPath(),"String_Node_Str");
  Assert.assertEquals(nestedProfile.azureEndpoints().size(),0);
  Assert.assertEquals(nestedProfile.nestedProfileEndpoints().size(),0);
  Assert.assertEquals(nestedProfile.externalEndpoints().size(),1);
  Assert.assertEquals(nestedProfile.fqdn(),nestedTmProfileDnsLabel + "String_Node_Str");
  Assert.assertEquals(nestedProfile.timeToLive(),500);
  PublicIPAddress publicIPAddress=this.publicIPAddresses.define(pipName).withRegion(region).withNewResourceGroup(rgCreatable).withLeafDomainLabel(pipDnsLabel).create();
  Assert.assertNotNull(publicIPAddress.fqdn());
  TrafficManagerProfile profile=profiles.define(tmProfileName).withNewResourceGroup(rgCreatable).withLeafDomainLabel(tmProfileDnsLabel).withWeightBasedRouting().defineExternalTargetEndpoint(externalEndpointName21).toFqdn(externalFqdn21).fromRegion(Region.US_EAST).withRoutingPriority(1).withRoutingWeight(1).attach().defineExternalTargetEndpoint(externalEndpointName22).toFqdn(externalFqdn22).fromRegion(Region.US_EAST2).withRoutingPriority(2).withRoutingWeight(1).withTrafficDisabled().attach().defineAzureTargetEndpoint(azureEndpointName).toResourceId(publicIPAddress.id()).withRoutingPriority(3).attach().defineNestedTargetEndpoint(nestedProfileEndpointName).toProfile(nestedProfile).fromRegion(Region.INDIA_CENTRAL).withMinimumEndpointsToEnableTraffic(1).withRoutingPriority(4).attach().withHttpMonitoring().create();
  Assert.assertTrue(profile.isEnabled());
  Assert.assertNotNull(profile.monitorStatus());
  Assert.assertEquals(profile.monitoringPort(),80);
  Assert.assertEquals(profile.monitoringPath(),"String_Node_Str");
  Assert.assertEquals(profile.azureEndpoints().size(),1);
  Assert.assertEquals(profile.nestedProfileEndpoints().size(),1);
  Assert.assertEquals(profile.externalEndpoints().size(),2);
  Assert.assertEquals(profile.fqdn(),tmProfileDnsLabel + "String_Node_Str");
  Assert.assertEquals(profile.timeToLive(),300);
  profile=profile.refresh();
  Assert.assertEquals(profile.azureEndpoints().size(),1);
  Assert.assertEquals(profile.nestedProfileEndpoints().size(),1);
  Assert.assertEquals(profile.externalEndpoints().size(),2);
  int c=0;
  for (  TrafficManagerExternalEndpoint endpoint : profile.externalEndpoints().values()) {
    Assert.assertEquals(endpoint.endpointType(),EndpointType.EXTERNAL);
    if (endpoint.name().equalsIgnoreCase(externalEndpointName21)) {
      Assert.assertEquals(endpoint.routingPriority(),1);
      Assert.assertEquals(endpoint.fqdn(),externalFqdn21);
      Assert.assertNotNull(endpoint.monitorStatus());
      Assert.assertEquals(endpoint.sourceTrafficLocation(),Region.US_EAST);
      c++;
    }
 else     if (endpoint.name().equalsIgnoreCase(externalEndpointName22)) {
      Assert.assertEquals(endpoint.routingPriority(),2);
      Assert.assertEquals(endpoint.fqdn(),externalFqdn22);
      Assert.assertNotNull(endpoint.monitorStatus());
      Assert.assertEquals(endpoint.sourceTrafficLocation(),Region.US_EAST2);
      c++;
    }
  }
  Assert.assertEquals(c,2);
  c=0;
  for (  TrafficManagerAzureEndpoint endpoint : profile.azureEndpoints().values()) {
    Assert.assertEquals(endpoint.endpointType(),EndpointType.AZURE);
    if (endpoint.name().equalsIgnoreCase(azureEndpointName)) {
      Assert.assertEquals(endpoint.routingPriority(),3);
      Assert.assertNotNull(endpoint.monitorStatus());
      Assert.assertEquals(endpoint.targetAzureResourceId(),publicIPAddress.id());
      Assert.assertEquals(endpoint.targetResourceType(),TargetAzureResourceType.PUBLICIP);
      c++;
    }
  }
  Assert.assertEquals(c,1);
  c=0;
  for (  TrafficManagerNestedProfileEndpoint endpoint : profile.nestedProfileEndpoints().values()) {
    Assert.assertEquals(endpoint.endpointType(),EndpointType.NESTED_PROFILE);
    if (endpoint.name().equalsIgnoreCase(nestedProfileEndpointName)) {
      Assert.assertEquals(endpoint.routingPriority(),4);
      Assert.assertNotNull(endpoint.monitorStatus());
      Assert.assertEquals(endpoint.minimumChildEndpointCount(),1);
      Assert.assertEquals(endpoint.nestedProfileId(),nestedProfile.id());
      Assert.assertEquals(endpoint.sourceTrafficLocation(),Region.INDIA_CENTRAL);
      c++;
    }
  }
  Assert.assertEquals(c,1);
  return profile;
}

Fixed version (ground truth):
@Override public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) throws Exception {
  final Region region=Region.US_EAST;
  final String groupName="String_Node_Str" + this.testId;
  final String pipName="String_Node_Str" + this.testId;
  final String pipDnsLabel=SdkContext.randomResourceName("String_Node_Str",15);
  final String tmProfileName="String_Node_Str" + this.testId;
  final String nestedTmProfileName="String_Node_Str" + tmProfileName;
  final String tmProfileDnsLabel=SdkContext.randomResourceName("String_Node_Str",15);
  final String nestedTmProfileDnsLabel="String_Node_Str" + tmProfileDnsLabel;
  ResourceGroup.DefinitionStages.WithCreate rgCreatable=profiles.manager().resourceManager().resourceGroups().define(groupName).withRegion(region);
  TrafficManagerProfile nestedProfile=profiles.define(nestedTmProfileName).withNewResourceGroup(rgCreatable).withLeafDomainLabel(nestedTmProfileDnsLabel).withPriorityBasedRouting().defineExternalTargetEndpoint("String_Node_Str").toFqdn("String_Node_Str").fromRegion(Region.INDIA_CENTRAL).attach().withHttpsMonitoring().withTimeToLive(500).create();
  Assert.assertTrue(nestedProfile.isEnabled());
  Assert.assertNotNull(nestedProfile.monitorStatus());
  Assert.assertEquals(nestedProfile.monitoringPort(),443);
  Assert.assertEquals(nestedProfile.monitoringPath(),"String_Node_Str");
  Assert.assertEquals(nestedProfile.azureEndpoints().size(),0);
  Assert.assertEquals(nestedProfile.nestedProfileEndpoints().size(),0);
  Assert.assertEquals(nestedProfile.externalEndpoints().size(),1);
  Assert.assertEquals(nestedProfile.fqdn(),nestedTmProfileDnsLabel + "String_Node_Str");
  Assert.assertEquals(nestedProfile.timeToLive(),500);
  PublicIPAddress publicIPAddress=this.publicIPAddresses.define(pipName).withRegion(region).withNewResourceGroup(rgCreatable).withLeafDomainLabel(pipDnsLabel).create();
  Assert.assertNotNull(publicIPAddress.fqdn());
  TrafficManagerProfile updatedProfile=nestedProfile.update().defineAzureTargetEndpoint(azureEndpointName).toResourceId(publicIPAddress.id()).withTrafficDisabled().withRoutingPriority(11).attach().apply();
  Assert.assertEquals(1,updatedProfile.azureEndpoints().size());
  Assert.assertTrue(updatedProfile.azureEndpoints().containsKey(azureEndpointName));
  TrafficManagerProfile updatedProfileFromGet=profiles.getById(updatedProfile.id());
  Assert.assertEquals(1,updatedProfileFromGet.azureEndpoints().size());
  Assert.assertTrue(updatedProfileFromGet.azureEndpoints().containsKey(azureEndpointName));
  nestedProfile.update().withoutEndpoint(azureEndpointName).apply();
  TrafficManagerProfile profile=profiles.define(tmProfileName).withNewResourceGroup(rgCreatable).withLeafDomainLabel(tmProfileDnsLabel).withWeightBasedRouting().defineExternalTargetEndpoint(externalEndpointName21).toFqdn(externalFqdn21).fromRegion(Region.US_EAST).withRoutingPriority(1).withRoutingWeight(1).attach().defineExternalTargetEndpoint(externalEndpointName22).toFqdn(externalFqdn22).fromRegion(Region.US_EAST2).withRoutingPriority(2).withRoutingWeight(1).withTrafficDisabled().attach().defineAzureTargetEndpoint(azureEndpointName).toResourceId(publicIPAddress.id()).withRoutingPriority(3).attach().defineNestedTargetEndpoint(nestedProfileEndpointName).toProfile(nestedProfile).fromRegion(Region.INDIA_CENTRAL).withMinimumEndpointsToEnableTraffic(1).withRoutingPriority(4).attach().withHttpMonitoring().create();
  Assert.assertTrue(profile.isEnabled());
  Assert.assertNotNull(profile.monitorStatus());
  Assert.assertEquals(profile.monitoringPort(),80);
  Assert.assertEquals(profile.monitoringPath(),"String_Node_Str");
  Assert.assertEquals(profile.azureEndpoints().size(),1);
  Assert.assertEquals(profile.nestedProfileEndpoints().size(),1);
  Assert.assertEquals(profile.externalEndpoints().size(),2);
  Assert.assertEquals(profile.fqdn(),tmProfileDnsLabel + "String_Node_Str");
  Assert.assertEquals(profile.timeToLive(),300);
  profile=profile.refresh();
  Assert.assertEquals(profile.azureEndpoints().size(),1);
  Assert.assertEquals(profile.nestedProfileEndpoints().size(),1);
  Assert.assertEquals(profile.externalEndpoints().size(),2);
  int c=0;
  for (  TrafficManagerExternalEndpoint endpoint : profile.externalEndpoints().values()) {
    Assert.assertEquals(endpoint.endpointType(),EndpointType.EXTERNAL);
    if (endpoint.name().equalsIgnoreCase(externalEndpointName21)) {
      Assert.assertEquals(endpoint.routingPriority(),1);
      Assert.assertEquals(endpoint.fqdn(),externalFqdn21);
      Assert.assertNotNull(endpoint.monitorStatus());
      Assert.assertEquals(endpoint.sourceTrafficLocation(),Region.US_EAST);
      c++;
    }
 else     if (endpoint.name().equalsIgnoreCase(externalEndpointName22)) {
      Assert.assertEquals(endpoint.routingPriority(),2);
      Assert.assertEquals(endpoint.fqdn(),externalFqdn22);
      Assert.assertNotNull(endpoint.monitorStatus());
      Assert.assertEquals(endpoint.sourceTrafficLocation(),Region.US_EAST2);
      c++;
    }
  }
  Assert.assertEquals(c,2);
  c=0;
  for (  TrafficManagerAzureEndpoint endpoint : profile.azureEndpoints().values()) {
    Assert.assertEquals(endpoint.endpointType(),EndpointType.AZURE);
    if (endpoint.name().equalsIgnoreCase(azureEndpointName)) {
      Assert.assertEquals(endpoint.routingPriority(),3);
      Assert.assertNotNull(endpoint.monitorStatus());
      Assert.assertEquals(endpoint.targetAzureResourceId(),publicIPAddress.id());
      Assert.assertEquals(endpoint.targetResourceType(),TargetAzureResourceType.PUBLICIP);
      c++;
    }
  }
  Assert.assertEquals(c,1);
  c=0;
  for (  TrafficManagerNestedProfileEndpoint endpoint : profile.nestedProfileEndpoints().values()) {
    Assert.assertEquals(endpoint.endpointType(),EndpointType.NESTED_PROFILE);
    if (endpoint.name().equalsIgnoreCase(nestedProfileEndpointName)) {
      Assert.assertEquals(endpoint.routingPriority(),4);
      Assert.assertNotNull(endpoint.monitorStatus());
      Assert.assertEquals(endpoint.minimumChildEndpointCount(),1);
      Assert.assertEquals(endpoint.nestedProfileId(),nestedProfile.id());
      Assert.assertEquals(endpoint.sourceTrafficLocation(),Region.INDIA_CENTRAL);
      c++;
    }
  }
  Assert.assertEquals(c,1);
  return profile;
}