Program: 114843
Project: 114843
Buggy source:
@Test(groups={"String_Node_Str"},description="String_Node_Str",enabled=true) public void testEnableJWTAndClaims() throws Exception {
  RemoteUserStoreManagerServiceClient remoteUserStoreManagerServiceClient=new RemoteUserStoreManagerServiceClient(keyManagerContext.getContextUrls().getBackEndUrl(),keyManagerContext.getContextTenant().getContextUser().getUserName(),keyManagerContext.getContextTenant().getContextUser().getPassword());
  String username=keyManagerContext.getContextTenant().getContextUser().getUserName();
  String profile="String_Node_Str";
  remoteUserStoreManagerServiceClient.setUserClaimValue(username,"String_Node_Str","String_Node_Str",profile);
  remoteUserStoreManagerServiceClient.setUserClaimValue(username,"String_Node_Str","String_Node_Str",profile);
  serverConfigurationManager.restartGracefully();
  addAPI(apiName,apiVersion,apiContext,description,wireMonitorURL,tags,providerName);
  APIStoreRestClient apiStoreRestClient=new APIStoreRestClient(storeURLHttp);
  apiStoreRestClient.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  apiStoreRestClient.addApplication(applicationName,APIMIntegrationConstants.APPLICATION_TIER.LARGE,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(apiName,storeContext.getContextTenant().getContextUser().getUserName());
  subscriptionRequest.setApplicationName(applicationName);
  apiStoreRestClient.subscribe(subscriptionRequest);
  APPKeyRequestGenerator generateAppKeyRequest=new APPKeyRequestGenerator(applicationName);
  String responseString=apiStoreRestClient.generateApplicationKey(generateAppKeyRequest).getData();
  JSONObject response=new JSONObject(responseString);
  if (response.getJSONObject("String_Node_Str") == null) {
    serverConfigurationManager.restartGracefully();
    Thread.sleep(10000);
    responseString=apiStoreRestClient.generateApplicationKey(generateAppKeyRequest).getData();
    response=new JSONObject(responseString);
  }
  String accessToken=response.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").get("String_Node_Str").toString();
  String url=gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str";
  APIMTestCaseUtils.sendGetRequest(url,accessToken);
  String serverMessage=server.getCapturedMessage();
  String decodedJWTHeaderString=APIMTestCaseUtils.getDecodedURLSafeJWTHeader(serverMessage);
  if (decodedJWTHeaderString != null) {
    log.debug("String_Node_Str" + decodedJWTHeaderString);
    JSONObject jsonHeaderObject=new JSONObject(decodedJWTHeaderString);
    Assert.assertEquals(jsonHeaderObject.getString("String_Node_Str"),"String_Node_Str");
    Assert.assertEquals(jsonHeaderObject.getString("String_Node_Str"),"String_Node_Str");
  }
  String decodedJWTString=APIMTestCaseUtils.getDecodedURLSafeJWT(serverMessage);
  log.debug("String_Node_Str" + decodedJWTString);
  JSONObject jsonObject=new JSONObject(decodedJWTString);
  checkDefaultUserClaims(jsonObject);
  String claim=jsonObject.getString("String_Node_Str");
  assertTrue("String_Node_Str" + claim,claim.contains("String_Node_Str"));
  claim=jsonObject.getString("String_Node_Str");
  assertTrue("String_Node_Str" + claim,claim.contains("String_Node_Str"));
  boolean bExceptionOccured=false;
  try {
    jsonObject.getString("String_Node_Str");
  }
 catch (  JSONException e) {
    bExceptionOccured=true;
  }
  assertTrue("String_Node_Str",bExceptionOccured);
  Thread.sleep(20000);
  Thread.sleep(20000);
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str"},description="String_Node_Str",enabled=true) public void testEnableJWTAndClaims() throws Exception {
  RemoteUserStoreManagerServiceClient remoteUserStoreManagerServiceClient=new RemoteUserStoreManagerServiceClient(keyManagerContext.getContextUrls().getBackEndUrl(),user.getUserName(),user.getPassword());
  String profile="String_Node_Str";
  remoteUserStoreManagerServiceClient.setUserClaimValue(user.getUserNameWithoutDomain(),"String_Node_Str","String_Node_Str",profile);
  remoteUserStoreManagerServiceClient.setUserClaimValue(user.getUserNameWithoutDomain(),"String_Node_Str","String_Node_Str",profile);
  ServerConfigurationManager serverConfigManagerForTenant=new ServerConfigurationManager(superTenantKeyManagerContext);
  serverConfigManagerForTenant.restartGracefully();
  super.init(userMode);
  addAPI(apiName,apiVersion,apiContext,description,wireMonitorURL,tags,providerName);
  APIStoreRestClient apiStoreRestClient=new APIStoreRestClient(storeURLHttp);
  apiStoreRestClient.login(user.getUserName(),user.getPassword());
  apiStoreRestClient.addApplication(applicationName,APIMIntegrationConstants.APPLICATION_TIER.LARGE,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(apiName,user.getUserName());
  subscriptionRequest.setApplicationName(applicationName);
  apiStoreRestClient.subscribe(subscriptionRequest);
  APPKeyRequestGenerator generateAppKeyRequest=new APPKeyRequestGenerator(applicationName);
  String responseString=apiStoreRestClient.generateApplicationKey(generateAppKeyRequest).getData();
  JSONObject response=new JSONObject(responseString);
  String accessToken=response.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").get("String_Node_Str").toString();
  String url=getAPIInvocationURLHttp("String_Node_Str","String_Node_Str");
  APIMTestCaseUtils.sendGetRequest(url,accessToken);
  String serverMessage=server.getCapturedMessage();
  log.info("String_Node_Str" + serverMessage);
  String decodedJWTHeaderString=APIMTestCaseUtils.getDecodedURLSafeJWTHeader(serverMessage);
  if (decodedJWTHeaderString != null) {
    log.debug("String_Node_Str" + decodedJWTHeaderString);
    JSONObject jsonHeaderObject=new JSONObject(decodedJWTHeaderString);
    Assert.assertEquals(jsonHeaderObject.getString("String_Node_Str"),"String_Node_Str");
    Assert.assertEquals(jsonHeaderObject.getString("String_Node_Str"),"String_Node_Str");
  }
  String decodedJWTString=APIMTestCaseUtils.getDecodedURLSafeJWT(serverMessage);
  log.debug("String_Node_Str" + decodedJWTString);
  JSONObject jsonObject=new JSONObject(decodedJWTString);
  checkDefaultUserClaims(jsonObject);
  String claim=jsonObject.getString("String_Node_Str");
  assertTrue("String_Node_Str" + claim,claim.contains("String_Node_Str"));
  claim=jsonObject.getString("String_Node_Str");
  assertTrue("String_Node_Str" + claim,claim.contains("String_Node_Str"));
  boolean bExceptionOccured=false;
  try {
    jsonObject.getString("String_Node_Str");
  }
 catch (  JSONException e) {
    bExceptionOccured=true;
  }
  assertTrue("String_Node_Str",bExceptionOccured);
}