Program: 15670
Project: 15670
Buggy source:
/** 
 * Test of the subscription resource.
 * @throws JSONException
 */
@Test public void testSubscriptionAddResource() throws JSONException {
  clientUtil.createUser("String_Node_Str");
  String subscription1AuthToken=clientUtil.login("String_Node_Str");
  WebResource categoryResource=resource().path("String_Node_Str");
  categoryResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  MultivaluedMapImpl postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str","String_Node_Str");
  ClientResponse response=categoryResource.put(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  JSONObject json=response.getEntity(JSONObject.class);
  String category1Id=json.optString("String_Node_Str");
  Assert.assertNotNull(category1Id);
  WebResource subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.put(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  String subscription1Id=json.getString("String_Node_Str");
  Assert.assertNotNull(subscription1Id);
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str",category1Id);
  response=subscriptionResource.post(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  int unreadCount=json.optInt("String_Node_Str");
  Assert.assertTrue(unreadCount > 0);
  JSONArray categories=json.optJSONArray("String_Node_Str");
  Assert.assertNotNull(categories);
  Assert.assertEquals(1,categories.length());
  JSONObject rootCategory=categories.optJSONObject(0);
  categories=rootCategory.getJSONArray("String_Node_Str");
  JSONObject technoCategory=categories.optJSONObject(0);
  JSONArray subscriptions=technoCategory.optJSONArray("String_Node_Str");
  Assert.assertEquals(1,subscriptions.length());
  JSONObject subscription=subscriptions.getJSONObject(0);
  Assert.assertEquals(10,subscription.getInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  subscription=json.optJSONObject("String_Node_Str");
  Assert.assertNotNull(subscription);
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  JSONArray articles=json.optJSONArray("String_Node_Str");
  Assert.assertEquals(10,articles.length());
  JSONObject article=articles.optJSONObject(0);
  Assert.assertNotNull(article);
  String article1Id=article.getString("String_Node_Str");
  Assert.assertNotNull(article1Id);
  JSONObject articleSubscription=article.optJSONObject("String_Node_Str");
  Assert.assertNotNull(articleSubscription.getString("String_Node_Str"));
  Assert.assertNotNull(articleSubscription.getString("String_Node_Str"));
  Assert.assertNotNull(article.optString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str",1);
  postParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.post(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  subscription=json.optJSONObject("String_Node_Str");
  Assert.assertNotNull(subscription);
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  WebResource articleResource=resource().path("String_Node_Str" + article1Id + "String_Node_Str");
  articleResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  response=articleResource.post(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  MultivaluedMap<String,String> queryParams=new MultivaluedMapImpl();
  queryParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.queryParams(queryParams).get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(9,json.optInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(9,json.optInt("String_Node_Str"));
  articleResource=resource().path("String_Node_Str" + article1Id + "String_Node_Str");
  articleResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  response=articleResource.post(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  queryParams=new MultivaluedMapImpl();
  queryParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.queryParams(queryParams).get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(10,json.optInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id + "String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.post(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(0,json.optInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.delete(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Test of the subscription resource.
 * @throws JSONException
 */
@Test public void testSubscriptionAddResource() throws JSONException {
  clientUtil.createUser("String_Node_Str");
  String subscription1AuthToken=clientUtil.login("String_Node_Str");
  WebResource categoryResource=resource().path("String_Node_Str");
  categoryResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  MultivaluedMapImpl postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str","String_Node_Str");
  ClientResponse response=categoryResource.put(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  JSONObject json=response.getEntity(JSONObject.class);
  String category1Id=json.optString("String_Node_Str");
  Assert.assertNotNull(category1Id);
  WebResource subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.put(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  String subscription1Id=json.getString("String_Node_Str");
  Assert.assertNotNull(subscription1Id);
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str",category1Id);
  response=subscriptionResource.post(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  int unreadCount=json.optInt("String_Node_Str");
  Assert.assertTrue(unreadCount > 0);
  JSONArray categories=json.optJSONArray("String_Node_Str");
  Assert.assertNotNull(categories);
  Assert.assertEquals(1,categories.length());
  JSONObject rootCategory=categories.optJSONObject(0);
  categories=rootCategory.getJSONArray("String_Node_Str");
  JSONObject technoCategory=categories.optJSONObject(0);
  JSONArray subscriptions=technoCategory.optJSONArray("String_Node_Str");
  Assert.assertEquals(1,subscriptions.length());
  JSONObject subscription=subscriptions.getJSONObject(0);
  Assert.assertEquals(10,subscription.getInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  subscription=json.optJSONObject("String_Node_Str");
  Assert.assertNotNull(subscription);
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  JSONArray articles=json.optJSONArray("String_Node_Str");
  Assert.assertEquals(10,articles.length());
  JSONObject article=articles.optJSONObject(0);
  Assert.assertNotNull(article);
  String article1Id=article.getString("String_Node_Str");
  Assert.assertNotNull(article1Id);
  JSONObject articleSubscription=article.optJSONObject("String_Node_Str");
  Assert.assertNotNull(articleSubscription.getString("String_Node_Str"));
  Assert.assertNotNull(articleSubscription.getString("String_Node_Str"));
  Assert.assertNotNull(article.optString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str",1);
  postParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.post(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  subscription=json.optJSONObject("String_Node_Str");
  Assert.assertNotNull(subscription);
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",subscription.optString("String_Node_Str"));
  WebResource articleResource=resource().path("String_Node_Str" + article1Id + "String_Node_Str");
  articleResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  response=articleResource.post(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  MultivaluedMap<String,String> queryParams=new MultivaluedMapImpl();
  queryParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.queryParams(queryParams).get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(9,json.optInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  queryParams=new MultivaluedMapImpl();
  queryParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.queryParams(queryParams).get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(10,json.optInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(9,json.optInt("String_Node_Str"));
  articleResource=resource().path("String_Node_Str" + article1Id + "String_Node_Str");
  articleResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  postParams=new MultivaluedMapImpl();
  response=articleResource.post(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  queryParams=new MultivaluedMapImpl();
  queryParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.queryParams(queryParams).get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(10,json.optInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id + "String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.post(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals(0,json.optInt("String_Node_Str"));
  subscriptionResource=resource().path("String_Node_Str" + subscription1Id);
  subscriptionResource.addFilter(new CookieAuthenticationFilter(subscription1AuthToken));
  response=subscriptionResource.delete(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  Assert.assertEquals("String_Node_Str",json.getString("String_Node_Str"));
}