nus-yam/ex-repair huggingface dataset:
Program: 102479
Project: 102479
Buggy source:
/** 
 * Gets absolute link from the provided link
 * @param base
 * @param link
 * @return absolute link
 */
private String getAbsLink(String link){
  if (link.startsWith("String_Node_Str"))   return link;
  URL url=null;
  try {
    url=new URL(this.link);
  }
 catch (  MalformedURLException e) {
  }
  String protocol=url.getProtocol();
  String host=url.getHost();
  String base=protocol + "String_Node_Str" + host;
  if (link.startsWith("String_Node_Str")) {
    return base + link;
  }
 else   if (link.startsWith("String_Node_Str")) {
    if (this.link.endsWith("String_Node_Str")) {
      this.link=this.link.substring(0,this.link.length() - 1);
    }
    link=link.substring(1,link.length());
    return this.link + link;
  }
 else   if (link.startsWith("String_Node_Str")) {
    String regex="String_Node_Str";
    Pattern partern=Pattern.compile(regex);
    Matcher matcher=partern.matcher(link);
    int level=0;
    while (matcher.find()) {
      level++;
    }
    String secondPath=link.replace("String_Node_Str","String_Node_Str");
    String[] str=this.link.split("String_Node_Str");
    StringBuffer sb=new StringBuffer();
    level=(str.length - 1) - level;
    for (int i=0; i < level; i++) {
      sb.append(str[i]);
    }
    sb.append(secondPath);
    return sb.toString();
  }
 else {
    if (this.link.endsWith("String_Node_Str")) {
      return this.link + link;
    }
 else {
      return this.link + "String_Node_Str" + link;
    }
  }
}

Fixed version (ground truth):
/** 
 * Gets absolute link from the provided link
 * @param base
 * @param link
 * @return absolute link
 */
private String getAbsLink(String link){
  if (link.startsWith("String_Node_Str"))   return link;
  URL url=null;
  try {
    url=new URL(this.link);
  }
 catch (  MalformedURLException e) {
    LOG.debug("String_Node_Str");
  }
  String protocol=url.getProtocol();
  String host=url.getHost();
  String base=protocol + "String_Node_Str" + host;
  if (link.startsWith("String_Node_Str")) {
    return base + link;
  }
 else   if (link.startsWith("String_Node_Str")) {
    if (this.link.endsWith("String_Node_Str")) {
      this.link=this.link.substring(0,this.link.length() - 1);
    }
    link=link.substring(1,link.length());
    return this.link + link;
  }
 else   if (link.startsWith("String_Node_Str")) {
    String regex="String_Node_Str";
    Pattern partern=Pattern.compile(regex);
    Matcher matcher=partern.matcher(link);
    int level=0;
    while (matcher.find()) {
      level++;
    }
    String secondPath=link.replace("String_Node_Str","String_Node_Str");
    String[] str=this.link.split("String_Node_Str");
    StringBuffer sb=new StringBuffer();
    level=(str.length - 1) - level;
    for (int i=0; i < level; i++) {
      sb.append(str[i]);
    }
    sb.append(secondPath);
    return sb.toString();
  }
 else {
    if (this.link.endsWith("String_Node_Str")) {
      return this.link + link;
    }
 else {
      return this.link + "String_Node_Str" + link;
    }
  }
}
Program: 102480
Project: 102480
Buggy source:
private String getUserId(SecurityContext securityContext,UriInfo uriInfo){
  String userId=StringUtils.EMPTY;
  try {
    userId=ConversationState.getCurrent().getIdentity().getUserId();
  }
 catch (  Exception e) {
  }
  if (userId == null || userId.isEmpty() || IdentityConstants.ANONIM.equals(userId)) {
    if (securityContext != null && securityContext.getUserPrincipal() != null) {
      return securityContext.getUserPrincipal().getName();
    }
 else     if (uriInfo != null) {
      return Util.getViewerId(uriInfo);
    }
  }
  return userId;
}

Fixed version (ground truth):
private String getUserId(SecurityContext securityContext,UriInfo uriInfo){
  String userId=StringUtils.EMPTY;
  try {
    userId=ConversationState.getCurrent().getIdentity().getUserId();
  }
 catch (  Exception e) {
    LOG.debug("String_Node_Str");
  }
  if (userId == null || userId.isEmpty() || IdentityConstants.ANONIM.equals(userId)) {
    if (securityContext != null && securityContext.getUserPrincipal() != null) {
      return securityContext.getUserPrincipal().getName();
    }
 else     if (uriInfo != null) {
      return Util.getViewerId(uriInfo);
    }
  }
  return userId;
}
Program: 102483
Project: 102483
Buggy source:
public static String getRestUrl(String type,String objectId1,String objectId2){
  String baseUrl=getBaseRestUrl();
  return new StringBuffer(baseUrl).append("String_Node_Str").append(type).append("String_Node_Str").append(objectId1).append("String_Node_Str").append(objectId2).toString();
}

Fixed version (ground truth):
/** 
 * Gets full rest url
 * @param type
 * @param objectId1
 * @param objectId2
 * @return
 */
public static String getRestUrl(String type,String objectId1,String objectId2){
  String baseUrl=getBaseRestUrl();
  return new StringBuffer(baseUrl).append("String_Node_Str").append(type).append("String_Node_Str").append(objectId1).append("String_Node_Str").append(objectId2).toString();
}
Program: 102485
Project: 102485
Buggy source:
@Override public boolean isValid(NotificationContext ctx){
  ExoSocialActivity activity=ctx.value(ACTIVITY);
  Identity id=Utils.getIdentityManager().getOrCreateIdentity(SpaceIdentityProvider.NAME,activity.getStreamOwner(),false);
  return id != null;
}

Fixed version (ground truth):
@Override public boolean isValid(NotificationContext ctx){
  ExoSocialActivity activity=ctx.value(ACTIVITY);
  if (!Utils.isSpaceActivity(activity))   return false;
  Identity id=Utils.getIdentityManager().getIdentity(activity.getPosterId(),true);
  return !id.getRemoteId().equals(activity.getStreamOwner());
}
Program: 102486
Project: 102486
Buggy source:
@Override public NotificationMessage execute(NotificationContext ctx){
  try {
    ExoSocialActivity activity=ctx.value(ACTIVITY);
    Identity id=Utils.getIdentityManager().getIdentity(activity.getStreamOwner(),false);
    Space space=Utils.getSpaceService().getSpaceByPrettyName(id.getRemoteId());
    return NotificationMessage.getInstance().setProviderType(PROVIDER_TYPE).setFrom(Utils.getUserId(activity.getPosterId())).addOwnerParameter("String_Node_Str",activity.getId()).setSendToUserIds(Arrays.asList(space.getMembers()));
  }
 catch (  Exception e) {
    return null;
  }
}

Fixed version (ground truth):
@Override public NotificationMessage execute(NotificationContext ctx){
  try {
    ExoSocialActivity activity=ctx.value(ACTIVITY);
    Identity id=Utils.getIdentityManager().getOrCreateIdentity(SpaceIdentityProvider.NAME,activity.getStreamOwner(),false);
    Space space=Utils.getSpaceService().getSpaceByPrettyName(id.getRemoteId());
    return NotificationMessage.getInstance().setProviderType(PROVIDER_TYPE).setFrom(Utils.getUserId(activity.getPosterId())).addOwnerParameter("String_Node_Str",activity.getId()).setSendToUserIds(Utils.getDestinataires(activity,space));
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 102487
Project: 102487
Buggy source:
public void testSaveComment() throws Exception {
  ExoSocialActivity activity=new ExoSocialActivityImpl();
  activity.setTitle("String_Node_Str");
  activityManager.saveActivity(rootIdentity,activity);
  tearDownActivityList.add(activity);
  ExoSocialActivity comment=new ExoSocialActivityImpl();
  comment.setTitle("String_Node_Str");
  comment.setUserId(demoIdentity.getId());
  activityManager.saveComment(activity,comment);
  Collection<NotificationMessage> messages=Utils.getSocialEmailStorage().emails();
  assertEquals(2,messages.size());
  NotificationMessage message=messages.iterator().next();
  MessageInfo info=buildMessageInfo(message.setTo("String_Node_Str"));
  assertEquals("String_Node_Str" + demoIdentity.getProfile().getFullName(),info.getSubject());
  assertEquals("String_Node_Str" + activity.getTitle(),info.getBody());
}

Fixed version (ground truth):
public void testSaveComment() throws Exception {
  ExoSocialActivity activity=new ExoSocialActivityImpl();
  activity.setTitle("String_Node_Str");
  activity.setUserId(demoIdentity.getId());
  activityManager.saveActivity(rootIdentity,activity);
  tearDownActivityList.add(activity);
  ExoSocialActivity comment=new ExoSocialActivityImpl();
  comment.setTitle("String_Node_Str");
  comment.setUserId(demoIdentity.getId());
  activityManager.saveComment(activity,comment);
  Collection<NotificationMessage> messages=Utils.getSocialEmailStorage().emails();
  assertEquals(2,messages.size());
  NotificationMessage message=messages.iterator().next();
  MessageInfo info=buildMessageInfo(message.setTo("String_Node_Str"));
  assertEquals("String_Node_Str" + demoIdentity.getProfile().getFullName(),info.getSubject());
  assertEquals("String_Node_Str" + activity.getTitle(),info.getBody());
}
Program: 102488
Project: 102488
Buggy source:
public void testSaveActivity() throws Exception {
  ExoSocialActivity activity=new ExoSocialActivityImpl();
  activity.setTitle("String_Node_Str");
  activityManager.saveActivity(rootIdentity,activity);
  tearDownActivityList.add(activity);
  assertNotNull(activity.getId());
  assertEquals(1,Utils.getSocialEmailStorage().emails().size());
  ExoSocialActivity got=activityManager.getActivity(activity.getId());
  assertEquals(activity.getId(),got.getId());
  assertEquals(activity.getTitle(),got.getTitle());
  ExoSocialActivity act=new ExoSocialActivityImpl();
  act.setTitle("String_Node_Str");
  activityManager.saveActivity(rootIdentity,act);
  tearDownActivityList.add(act);
  assertNotNull(act.getId());
  assertEquals(2,Utils.getSocialEmailStorage().emails().size());
}

Fixed version (ground truth):
public void testSaveActivity() throws Exception {
  ExoSocialActivity activity=new ExoSocialActivityImpl();
  activity.setTitle("String_Node_Str");
  activity.setUserId(demoIdentity.getId());
  activityManager.saveActivity(rootIdentity,activity);
  tearDownActivityList.add(activity);
  assertNotNull(activity.getId());
  assertEquals(1,Utils.getSocialEmailStorage().emails().size());
  ExoSocialActivity got=activityManager.getActivity(activity.getId());
  assertEquals(activity.getId(),got.getId());
  assertEquals(activity.getTitle(),got.getTitle());
  ExoSocialActivity act=new ExoSocialActivityImpl();
  act.setTitle("String_Node_Str");
  act.setUserId(maryIdentity.getId());
  activityManager.saveActivity(rootIdentity,act);
  tearDownActivityList.add(act);
  assertNotNull(act.getId());
  assertEquals(2,Utils.getSocialEmailStorage().emails().size());
  Space space=getSpaceInstance(1);
  Identity spaceIdentity=CommonsUtils.getService(IdentityManager.class).getOrCreateIdentity(SpaceIdentityProvider.NAME,space.getPrettyName(),false);
  ExoSocialActivity spaceActivity=new ExoSocialActivityImpl();
  spaceActivity.setTitle("String_Node_Str");
  spaceActivity.setUserId(demoIdentity.getId());
  activityManager.saveActivity(spaceIdentity,spaceActivity);
  tearDownActivityList.add(spaceActivity);
  Collection<NotificationMessage> messages=Utils.getSocialEmailStorage().emails();
  assertEquals(1,messages.size());
  assertEquals(1,messages.iterator().next().getSendToUserIds().size());
  space.setMembers(new String[]{"String_Node_Str","String_Node_Str"});
  spaceService.saveSpace(space,false);
  ExoSocialActivity spaceActivity2=new ExoSocialActivityImpl();
  spaceActivity2.setTitle("String_Node_Str");
  spaceActivity2.setUserId(demoIdentity.getId());
  activityManager.saveActivity(spaceIdentity,spaceActivity2);
  tearDownActivityList.add(spaceActivity2);
  messages=Utils.getSocialEmailStorage().emails();
  assertEquals(1,messages.size());
  assertEquals(3,messages.iterator().next().getSendToUserIds().size());
  spaceService.deleteSpace(space);
}
Program: 102489
Project: 102489
Buggy source:
public void testLikeActivity() throws Exception {
  ExoSocialActivity activity=new ExoSocialActivityImpl();
  activity.setTitle("String_Node_Str");
  activityManager.saveActivity(rootIdentity,activity);
  tearDownActivityList.add(activity);
  assertEquals(1,Utils.getSocialEmailStorage().emails().size());
  activityManager.saveLike(activity,demoIdentity);
  assertEquals(1,Utils.getSocialEmailStorage().emails().size());
}

Fixed version (ground truth):
public void testLikeActivity() throws Exception {
  ExoSocialActivity activity=new ExoSocialActivityImpl();
  activity.setTitle("String_Node_Str");
  activity.setUserId(demoIdentity.getId());
  activityManager.saveActivity(rootIdentity,activity);
  tearDownActivityList.add(activity);
  assertEquals(1,Utils.getSocialEmailStorage().emails().size());
  activityManager.saveLike(activity,demoIdentity);
  assertEquals(1,Utils.getSocialEmailStorage().emails().size());
}
Program: 102490
Project: 102490
Buggy source:
@GET @Path("String_Node_Str") public Response ignoreInvitationToConnect(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String senderId,@PathParam("String_Node_Str") String receiverId) throws Exception {
  checkAuthenticatedRequest();
  Identity sender=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,senderId,true);
  Identity receiver=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,receiverId,true);
  getRelationshipManager().deny(sender,receiver);
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserConnectionsYoursUri(receiver.getRemoteId());
  return Response.seeOther(URI.create(targetURL)).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response ignoreInvitationToConnect(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String senderId,@PathParam("String_Node_Str") String receiverId) throws Exception {
  checkAuthenticatedRequest();
  Identity sender=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,senderId,true);
  Identity receiver=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,receiverId,true);
  if (sender == null || receiver == null) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  getRelationshipManager().deny(sender,receiver);
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserConnectionsYoursUri(receiver.getRemoteId());
  return Response.seeOther(URI.create(targetURL)).build();
}
Program: 102491
Project: 102491
Buggy source:
@GET @Path("String_Node_Str") public Response viewFullDiscussion(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String userId,@PathParam("String_Node_Str") String activityId) throws Exception {
  checkAuthenticatedRequest();
  ExoSocialActivity activity=getActivityManager().getActivity(activityId);
  Identity identity=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,userId,true);
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserActivityUri(identity.getRemoteId()) + ACTIVITY_ID_PREFIX+ activity.getId();
  return Response.seeOther(URI.create(targetURL)).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response viewFullDiscussion(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String userId,@PathParam("String_Node_Str") String activityId) throws Exception {
  checkAuthenticatedRequest();
  ExoSocialActivity activity=getActivityManager().getActivity(activityId);
  Identity identity=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,userId,true);
  if (identity == null || activity == null) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserActivityUri(identity.getRemoteId()) + ACTIVITY_ID_PREFIX+ activity.getId();
  return Response.seeOther(URI.create(targetURL)).build();
}
Program: 102492
Project: 102492
Buggy source:
@GET @Path("String_Node_Str") public Response confirmInvitationToConnect(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String senderId,@PathParam("String_Node_Str") String receiverId) throws Exception {
  checkAuthenticatedRequest();
  Identity sender=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,senderId,true);
  Identity receiver=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,receiverId,true);
  getRelationshipManager().confirm(sender,receiver);
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserActivityUri(sender.getRemoteId());
  return Response.seeOther(URI.create(targetURL)).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response confirmInvitationToConnect(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String senderId,@PathParam("String_Node_Str") String receiverId) throws Exception {
  checkAuthenticatedRequest();
  Identity sender=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,senderId,true);
  Identity receiver=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,receiverId,true);
  if (sender == null || receiver == null) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  getRelationshipManager().confirm(sender,receiver);
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserActivityUri(sender.getRemoteId());
  return Response.seeOther(URI.create(targetURL)).build();
}
Program: 102493
Project: 102493
Buggy source:
@GET @Path("String_Node_Str") public Response inviteToConnect(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String senderId,@PathParam("String_Node_Str") String receiverId) throws Exception {
  checkAuthenticatedRequest();
  Identity sender=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,senderId,true);
  Identity receiver=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,receiverId,true);
  getRelationshipManager().inviteToConnect(sender,receiver);
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserProfileUri(receiver.getRemoteId());
  return Response.seeOther(URI.create(targetURL)).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response inviteToConnect(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String senderId,@PathParam("String_Node_Str") String receiverId) throws Exception {
  checkAuthenticatedRequest();
  Identity sender=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,senderId,true);
  Identity receiver=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,receiverId,true);
  if (sender == null || receiver == null) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  getRelationshipManager().inviteToConnect(sender,receiver);
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserProfileUri(receiver.getRemoteId());
  return Response.seeOther(URI.create(targetURL)).build();
}
Program: 102494
Project: 102494
Buggy source:
@GET @Path("String_Node_Str") public Response ignoreInvitationToJoinSpace(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String spaceId,@PathParam("String_Node_Str") String userId) throws Exception {
  checkAuthenticatedRequest();
  Space space=getSpaceService().getSpaceById(spaceId);
  getSpaceService().removeInvitedUser(space,userId);
  String targetURL=Util.getBaseUrl() + LinkProvider.getActivityUriForSpace(space.getGroupId().replace("String_Node_Str","String_Node_Str"),space.getPrettyName());
  return Response.seeOther(URI.create(targetURL)).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response ignoreInvitationToJoinSpace(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String spaceId,@PathParam("String_Node_Str") String userId) throws Exception {
  checkAuthenticatedRequest();
  Space space=getSpaceService().getSpaceById(spaceId);
  if (space == null) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  getSpaceService().removeInvitedUser(space,userId);
  String targetURL=Util.getBaseUrl() + LinkProvider.getActivityUriForSpace(space.getGroupId().replace("String_Node_Str","String_Node_Str"),space.getPrettyName());
  return Response.seeOther(URI.create(targetURL)).build();
}
Program: 102495
Project: 102495
Buggy source:
@GET @Path("String_Node_Str") public Response replyActivity(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String userId,@PathParam("String_Node_Str") String activityId) throws Exception {
  checkAuthenticatedRequest();
  ExoSocialActivity activity=getActivityManager().getActivity(activityId);
  Identity identity=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,userId,true);
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserActivityUri(identity.getRemoteId()) + ACTIVITY_ID_PREFIX+ activity.getId();
  return Response.seeOther(URI.create(targetURL)).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response replyActivity(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String userId,@PathParam("String_Node_Str") String activityId) throws Exception {
  checkAuthenticatedRequest();
  ExoSocialActivity activity=getActivityManager().getActivity(activityId);
  Identity identity=getIdentityManager().getOrCreateIdentity(OrganizationIdentityProvider.NAME,userId,true);
  if (identity == null || activity == null) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  String targetURL=Util.getBaseUrl() + LinkProvider.getUserActivityUri(identity.getRemoteId()) + ACTIVITY_ID_PREFIX+ activity.getId();
  return Response.seeOther(URI.create(targetURL)).build();
}
Program: 102496
Project: 102496
Buggy source:
@GET @Path("String_Node_Str") public Response validateRequestToJoinSpace(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String spaceId,@PathParam("String_Node_Str") String userId) throws Exception {
  checkAuthenticatedRequest();
  Space space=getSpaceService().getSpaceById(spaceId);
  getSpaceService().addMember(space,userId);
  String targetURL=Util.getBaseUrl() + LinkProvider.getActivityUriForSpace(space.getGroupId().replace("String_Node_Str","String_Node_Str"),space.getPrettyName()) + "String_Node_Str";
  return Response.seeOther(URI.create(targetURL)).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response validateRequestToJoinSpace(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String spaceId,@PathParam("String_Node_Str") String userId) throws Exception {
  checkAuthenticatedRequest();
  Space space=getSpaceService().getSpaceById(spaceId);
  if (space == null) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  getSpaceService().addMember(space,userId);
  String targetURL=Util.getBaseUrl() + LinkProvider.getActivityUriForSpace(space.getGroupId().replace("String_Node_Str","String_Node_Str"),space.getPrettyName()) + "String_Node_Str";
  return Response.seeOther(URI.create(targetURL)).build();
}
Program: 102497
Project: 102497
Buggy source:
@GET @Path("String_Node_Str") public Response acceptInvitationToJoinSpace(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String spaceId,@PathParam("String_Node_Str") String userId) throws Exception {
  checkAuthenticatedRequest();
  Space space=getSpaceService().getSpaceById(spaceId);
  getSpaceService().addMember(space,userId);
  String targetURL=Util.getBaseUrl() + LinkProvider.getActivityUriForSpace(space.getGroupId().replace("String_Node_Str","String_Node_Str"),space.getPrettyName());
  return Response.seeOther(URI.create(targetURL)).build();
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public Response acceptInvitationToJoinSpace(@Context UriInfo uriInfo,@PathParam("String_Node_Str") String spaceId,@PathParam("String_Node_Str") String userId) throws Exception {
  checkAuthenticatedRequest();
  Space space=getSpaceService().getSpaceById(spaceId);
  if (space == null) {
    throw new WebApplicationException(Response.Status.BAD_REQUEST);
  }
  getSpaceService().addMember(space,userId);
  String targetURL=Util.getBaseUrl() + LinkProvider.getActivityUriForSpace(space.getGroupId().replace("String_Node_Str","String_Node_Str"),space.getPrettyName());
  return Response.seeOther(URI.create(targetURL)).build();
}
Program: 102498
Project: 102498
Buggy source:
public void initSettingForm(){
  activeProviders=CommonsUtils.getService(ProviderSettingService.class).getActiveProviderIds(isAdmin());
  String checkBoxId;
  for (  String providerId : activeProviders) {
    for (int i=0; i < frequencies.length; ++i) {
      checkBoxId=getCheckBoxId(providerId,frequencies[i].getName());
      addUIFormInput(new UICheckBoxInput(checkBoxId,checkBoxId,false));
    }
  }
}

Fixed version (ground truth):
public void initSettingForm(){
  UserNotificationSetting notificationSetting=getUserNotificationService().getUserNotificationSetting(Utils.getOwnerRemoteId());
  activeProviders=CommonsUtils.getService(ProviderSettingService.class).getActiveProviderIds(isAdmin());
  String checkBoxId;
  for (  String providerId : activeProviders) {
    for (int i=0; i < frequencies.length; ++i) {
      checkBoxId=getCheckBoxId(providerId,frequencies[i].getName());
      addUIFormInput(new UICheckBoxInput(checkBoxId,checkBoxId,isCheckAcitve(notificationSetting,frequencies[i].getName(),providerId)));
    }
  }
}
Program: 102500
Project: 102500
Buggy source:
/** 
 * @throws Exception
 */
public void testSpaceCreation() throws Exception {
  Identity rootIdentity=identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME,"String_Node_Str");
  Space space=new Space();
  space.setDisplayName("String_Node_Str");
  space.setPrettyName(space.getDisplayName());
  space.setGroupId("String_Node_Str");
  space.setVisibility(Space.PRIVATE);
  spaceService.saveSpace(space,true);
  assertNotNull("String_Node_Str",space.getId());
  SpaceLifeCycleEvent event=new SpaceLifeCycleEvent(space,rootIdentity.getRemoteId(),SpaceLifeCycleEvent.Type.SPACE_CREATED);
  spaceActivityPublisher.spaceCreated(event);
  Thread.sleep(3000);
  Identity identity=identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME,space.getPrettyName());
  List<ExoSocialActivity> activities=activityManager.getActivities(identity);
  assertEquals(1,activities.size());
  tearDownActivityList.add(activities.get(0));
  assertTrue(activities.get(0).getTitle().contains(space.getDisplayName()));
  assertTrue(activities.get(0).getTitle().contains("String_Node_Str"));
  ActivityStream activityStream=activities.get(0).getActivityStream();
  assertNotNull("String_Node_Str",activityStream.getId());
  assertEquals("String_Node_Str" + space.getPrettyName(),space.getPrettyName(),activityStream.getPrettyId());
  assertEquals(ActivityStream.Type.SPACE,activityStream.getType());
  assertEquals(SpaceIdentityProvider.NAME,activityStream.getType().toString());
  spaceService.deleteSpace(space);
  identityManager.deleteIdentity(rootIdentity);
}

Fixed version (ground truth):
/** 
 * @throws Exception
 */
public void testSpaceCreation() throws Exception {
  Identity rootIdentity=identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME,"String_Node_Str");
  Space space=new Space();
  space.setDisplayName("String_Node_Str");
  space.setPrettyName(space.getDisplayName());
  space.setGroupId("String_Node_Str");
  space.setVisibility(Space.PRIVATE);
  spaceService.saveSpace(space,true);
  assertNotNull("String_Node_Str",space.getId());
  SpaceLifeCycleEvent event=new SpaceLifeCycleEvent(space,rootIdentity.getRemoteId(),SpaceLifeCycleEvent.Type.SPACE_CREATED);
  spaceActivityPublisher.spaceCreated(event);
  Thread.sleep(3000);
  Identity identity=identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME,space.getPrettyName());
  List<ExoSocialActivity> activities=activityManager.getActivities(identity);
  assertEquals(1,activities.size());
  tearDownActivityList.add(activities.get(0));
  ActivityStream activityStream=activities.get(0).getActivityStream();
  assertNotNull("String_Node_Str",activityStream.getId());
  assertEquals("String_Node_Str" + space.getPrettyName(),space.getPrettyName(),activityStream.getPrettyId());
  assertEquals(ActivityStream.Type.SPACE,activityStream.getType());
  assertEquals(SpaceIdentityProvider.NAME,activityStream.getType().toString());
  spaceService.deleteSpace(space);
  identityManager.deleteIdentity(rootIdentity);
}
Program: 102501
Project: 102501
Buggy source:
public SpaceFilterKey(String userId,SpaceFilter filter,SpaceType type){
  this.userId=userId;
  if (filter != null) {
    this.firstCharacterOfSpaceName=filter.getFirstCharacterOfSpaceName();
    this.spaceNameSearchCondition=filter.getSpaceNameSearchCondition();
  }
  this.type=type;
  this.sorting=filter.getSorting();
}

Fixed version (ground truth):
public SpaceFilterKey(String userId,SpaceFilter filter,SpaceType type){
  this.userId=userId;
  if (filter != null) {
    this.firstCharacterOfSpaceName=filter.getFirstCharacterOfSpaceName();
    this.spaceNameSearchCondition=filter.getSpaceNameSearchCondition();
    this.sorting=filter.getSorting();
  }
  this.type=type;
}
Program: 102502
Project: 102502
Buggy source:
/** 
 * Tests   {@link IdenityStorage#getIdentitiesByProfileFilter(String,ProfileFilter,int,int,boolean)}
 */
@MaxQueryNumber(600) public void testFindManyIdentitiesByProfileFilter() throws Exception {
  String providerId="String_Node_Str";
  int total=10;
  for (int i=0; i < total; i++) {
    String remoteId="String_Node_Str" + i;
    Identity identity=new Identity(providerId,remoteId);
    identityStorage.saveIdentity(identity);
    Profile profile=new Profile(identity);
    profile.setProperty(Profile.FIRST_NAME,"String_Node_Str" + i);
    profile.setProperty(Profile.LAST_NAME,"String_Node_Str");
    profile.setProperty(Profile.FULL_NAME,"String_Node_Str" + i + "String_Node_Str"+ "String_Node_Str"+ i);
    profile.setProperty(Profile.POSITION,"String_Node_Str");
    profile.setProperty(Profile.GENDER,"String_Node_Str");
    identity.setProfile(profile);
    tearDownIdentityList.add(identity);
    identityStorage.saveProfile(profile);
  }
  final ProfileFilter filter=new ProfileFilter();
  filter.setPosition("String_Node_Str");
  filter.setName("String_Node_Str");
  final List<Identity> result=identityStorage.getIdentitiesByProfileFilter(providerId,filter,0,total,false);
  assertEquals(total,result.size());
}

Fixed version (ground truth):
/** 
 * Tests   {@link IdenityStorage#getIdentitiesByProfileFilter(String,ProfileFilter,int,int,boolean)}
 */
@MaxQueryNumber(630) public void testFindManyIdentitiesByProfileFilter() throws Exception {
  String providerId="String_Node_Str";
  int total=10;
  for (int i=0; i < total; i++) {
    String remoteId="String_Node_Str" + i;
    Identity identity=new Identity(providerId,remoteId);
    identityStorage.saveIdentity(identity);
    Profile profile=new Profile(identity);
    profile.setProperty(Profile.FIRST_NAME,"String_Node_Str" + i);
    profile.setProperty(Profile.LAST_NAME,"String_Node_Str");
    profile.setProperty(Profile.FULL_NAME,"String_Node_Str" + i + "String_Node_Str"+ "String_Node_Str"+ i);
    profile.setProperty(Profile.POSITION,"String_Node_Str");
    profile.setProperty(Profile.GENDER,"String_Node_Str");
    identity.setProfile(profile);
    tearDownIdentityList.add(identity);
    identityStorage.saveProfile(profile);
  }
  final ProfileFilter filter=new ProfileFilter();
  filter.setPosition("String_Node_Str");
  filter.setName("String_Node_Str");
  final List<Identity> result=identityStorage.getIdentitiesByProfileFilter(providerId,filter,0,total,false);
  assertEquals(total,result.size());
}
Program: 102503
Project: 102503
Buggy source:
/** 
 * Tests   {@link IdenityStorage#getIdentitiesByFirstCharaterOfNameCount(String,char)}
 */
@MaxQueryNumber(550) public void testGetIdentitiesByFirstCharacterOfNameCount() throws Exception {
  populateData();
  final ProfileFilter filter=new ProfileFilter();
  filter.setFirstCharacterOfName('F');
  int idsCount=identityStorage.getIdentitiesByFirstCharacterOfNameCount("String_Node_Str",filter);
  assertEquals("String_Node_Str" + idsCount,0,idsCount);
  filter.setFirstCharacterOfName('L');
  idsCount=identityStorage.getIdentitiesByFirstCharacterOfNameCount("String_Node_Str",filter);
  assertEquals("String_Node_Str" + idsCount,10,idsCount);
}

Fixed version (ground truth):
/** 
 * Tests   {@link IdenityStorage#getIdentitiesByFirstCharaterOfNameCount(String,char)}
 */
@MaxQueryNumber(570) public void testGetIdentitiesByFirstCharacterOfNameCount() throws Exception {
  populateData();
  final ProfileFilter filter=new ProfileFilter();
  filter.setFirstCharacterOfName('F');
  int idsCount=identityStorage.getIdentitiesByFirstCharacterOfNameCount("String_Node_Str",filter);
  assertEquals("String_Node_Str" + idsCount,0,idsCount);
  filter.setFirstCharacterOfName('L');
  idsCount=identityStorage.getIdentitiesByFirstCharacterOfNameCount("String_Node_Str",filter);
  assertEquals("String_Node_Str" + idsCount,10,idsCount);
}
Program: 102504
Project: 102504
Buggy source:
@MaxQueryNumber(600) public void testGetSpaceMemberByProfileFilter() throws Exception {
  populateData();
  Space space=new Space();
  space.setApp("String_Node_Str");
  space.setDisplayName("String_Node_Str");
  space.setPrettyName(space.getDisplayName());
  space.setRegistration(Space.OPEN);
  space.setDescription("String_Node_Str");
  space.setType(DefaultSpaceApplicationHandler.NAME);
  space.setVisibility(Space.PUBLIC);
  space.setPriority(Space.INTERMEDIATE_PRIORITY);
  space.setGroupId("String_Node_Str");
  space.setUrl(space.getPrettyName());
  String[] managers=new String[]{};
  String[] members=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  String[] invitedUsers=new String[]{};
  String[] pendingUsers=new String[]{};
  space.setInvitedUsers(invitedUsers);
  space.setPendingUsers(pendingUsers);
  space.setManagers(managers);
  space.setMembers(members);
  spaceStorage.saveSpace(space,true);
  tearDownSpaceList.add(space);
  ProfileFilter profileFilter=new ProfileFilter();
  List<Identity> identities=identityStorage.getSpaceMemberIdentitiesByProfileFilter(space,profileFilter,Type.MEMBER,0,2);
  assertEquals(2,identities.size());
  profileFilter.setName("String_Node_Str");
  identities=identityStorage.getSpaceMemberIdentitiesByProfileFilter(space,profileFilter,Type.MEMBER,0,2);
  assertEquals(0,identities.size());
  profileFilter.setName("String_Node_Str");
  identities=identityStorage.getSpaceMemberIdentitiesByProfileFilter(space,profileFilter,Type.MEMBER,0,2);
  assertEquals(1,identities.size());
}

Fixed version (ground truth):
@MaxQueryNumber(610) public void testGetSpaceMemberByProfileFilter() throws Exception {
  populateData();
  Space space=new Space();
  space.setApp("String_Node_Str");
  space.setDisplayName("String_Node_Str");
  space.setPrettyName(space.getDisplayName());
  space.setRegistration(Space.OPEN);
  space.setDescription("String_Node_Str");
  space.setType(DefaultSpaceApplicationHandler.NAME);
  space.setVisibility(Space.PUBLIC);
  space.setPriority(Space.INTERMEDIATE_PRIORITY);
  space.setGroupId("String_Node_Str");
  space.setUrl(space.getPrettyName());
  String[] managers=new String[]{};
  String[] members=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  String[] invitedUsers=new String[]{};
  String[] pendingUsers=new String[]{};
  space.setInvitedUsers(invitedUsers);
  space.setPendingUsers(pendingUsers);
  space.setManagers(managers);
  space.setMembers(members);
  spaceStorage.saveSpace(space,true);
  tearDownSpaceList.add(space);
  ProfileFilter profileFilter=new ProfileFilter();
  List<Identity> identities=identityStorage.getSpaceMemberIdentitiesByProfileFilter(space,profileFilter,Type.MEMBER,0,2);
  assertEquals(2,identities.size());
  profileFilter.setName("String_Node_Str");
  identities=identityStorage.getSpaceMemberIdentitiesByProfileFilter(space,profileFilter,Type.MEMBER,0,2);
  assertEquals(0,identities.size());
  profileFilter.setName("String_Node_Str");
  identities=identityStorage.getSpaceMemberIdentitiesByProfileFilter(space,profileFilter,Type.MEMBER,0,2);
  assertEquals(1,identities.size());
}
Program: 102505
Project: 102505
Buggy source:
/** 
 * Tests   {@link IdenityStorage#getIdentitiesByProfileFilterCount(String,ProfileFilter)}
 */
@MaxQueryNumber(550) public void testGetIdentitiesByProfileFilterCount() throws Exception {
  populateData();
  ProfileFilter pf=new ProfileFilter();
  int idsCount=identityStorage.getIdentitiesByProfileFilterCount("String_Node_Str",pf);
  assertEquals(10,idsCount);
  pf.setPosition("String_Node_Str");
  pf.setName("String_Node_Str");
  idsCount=identityStorage.getIdentitiesByProfileFilterCount("String_Node_Str",pf);
  assertEquals(10,idsCount);
  pf.setName("String_Node_Str");
  idsCount=identityStorage.getIdentitiesByProfileFilterCount("String_Node_Str",pf);
  assertEquals(10,idsCount);
}

Fixed version (ground truth):
/** 
 * Tests   {@link IdenityStorage#getIdentitiesByProfileFilterCount(String,ProfileFilter)}
 */
@MaxQueryNumber(570) public void testGetIdentitiesByProfileFilterCount() throws Exception {
  populateData();
  ProfileFilter pf=new ProfileFilter();
  int idsCount=identityStorage.getIdentitiesByProfileFilterCount("String_Node_Str",pf);
  assertEquals(10,idsCount);
  pf.setPosition("String_Node_Str");
  pf.setName("String_Node_Str");
  idsCount=identityStorage.getIdentitiesByProfileFilterCount("String_Node_Str",pf);
  assertEquals(10,idsCount);
  pf.setName("String_Node_Str");
  idsCount=identityStorage.getIdentitiesByProfileFilterCount("String_Node_Str",pf);
  assertEquals(10,idsCount);
}
Program: 102506
Project: 102506
Buggy source:
/** 
 * Tests   {@link IdenityStorage#getIdentitiesCount(String)}
 */
@MaxQueryNumber(550) public void testGetIdentitiesCount() throws Exception {
  populateData();
  int identitiesCount=identityStorage.getIdentitiesCount(OrganizationIdentityProvider.NAME);
  assertEquals("String_Node_Str" + identitiesCount,10,identitiesCount);
}

Fixed version (ground truth):
/** 
 * Tests   {@link IdenityStorage#getIdentitiesCount(String)}
 */
@MaxQueryNumber(570) public void testGetIdentitiesCount() throws Exception {
  populateData();
  int identitiesCount=identityStorage.getIdentitiesCount(OrganizationIdentityProvider.NAME);
  assertEquals("String_Node_Str" + identitiesCount,10,identitiesCount);
}
Program: 102507
Project: 102507
Buggy source:
/** 
 * Tests   {@link IdenityStorage#getIdentitiesByProfileFilterCount(String,ProfileFilter,int,int,boolean)}
 */
@MaxQueryNumber(600) public void testGetIdentitiesByProfileFilterAccessList() throws Exception {
}

Fixed version (ground truth):
/** 
 * Tests   {@link IdenityStorage#getIdentitiesByProfileFilterCount(String,ProfileFilter,int,int,boolean)}
 */
@MaxQueryNumber(630) public void testGetIdentitiesByProfileFilterAccessList() throws Exception {
}
Program: 102508
Project: 102508
Buggy source:
@MaxQueryNumber(50) public void testLoadProfileByReloadCreatedProfileNode() throws Exception {
  String providerId="String_Node_Str";
  String remoteId="String_Node_Str";
  Identity identity=new Identity(providerId,remoteId);
  identityStorage.saveIdentity(identity);
  String profileId;
{
    Profile profile=new Profile(identity);
    assertFalse(profile.hasChanged());
    profile=identityStorage.loadProfile(profile);
    assertFalse(profile.hasChanged());
    profileId=profile.getId();
  }
{
    Profile profile=new Profile(identity);
    assertFalse(profile.hasChanged());
    profile=identityStorage.loadProfile(profile);
    assertFalse(profile.hasChanged());
    assertEquals(profileId,profile.getId());
  }
  tearDownIdentityList.add(identityStorage.findIdentity(OrganizationIdentityProvider.NAME,remoteId));
}

Fixed version (ground truth):
@MaxQueryNumber(60) public void testLoadProfileByReloadCreatedProfileNode() throws Exception {
  String providerId="String_Node_Str";
  String remoteId="String_Node_Str";
  Identity identity=new Identity(providerId,remoteId);
  identityStorage.saveIdentity(identity);
  String profileId;
{
    Profile profile=new Profile(identity);
    assertFalse(profile.hasChanged());
    profile=identityStorage.loadProfile(profile);
    assertFalse(profile.hasChanged());
    profileId=profile.getId();
  }
{
    Profile profile=new Profile(identity);
    assertFalse(profile.hasChanged());
    profile=identityStorage.loadProfile(profile);
    assertFalse(profile.hasChanged());
    assertEquals(profileId,profile.getId());
  }
  tearDownIdentityList.add(identityStorage.findIdentity(OrganizationIdentityProvider.NAME,remoteId));
}
Program: 102509
Project: 102509
Buggy source:
@MaxQueryNumber(50) public void testFindIdentityByNotExistName() throws Exception {
  String providerId="String_Node_Str";
  String remoteId="String_Node_Str";
  Identity identity=new Identity(providerId,remoteId);
  identityStorage.saveIdentity(identity);
  Profile profile=new Profile(identity);
  profile.setProperty(Profile.FIRST_NAME,"String_Node_Str");
  profile.setProperty(Profile.LAST_NAME,"String_Node_Str");
  profile.setProperty(Profile.FULL_NAME,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  identityStorage.saveProfile(profile);
  identity.setProfile(profile);
  tearDownIdentityList.add(identity);
  final ProfileFilter filter=new ProfileFilter();
  filter.setName("String_Node_Str");
  final List<Identity> result=identityStorage.getIdentitiesByProfileFilter(providerId,filter,0,1,false);
  assertEquals(0,result.size());
}

Fixed version (ground truth):
@MaxQueryNumber(60) public void testFindIdentityByNotExistName() throws Exception {
  String providerId="String_Node_Str";
  String remoteId="String_Node_Str";
  Identity identity=new Identity(providerId,remoteId);
  identityStorage.saveIdentity(identity);
  Profile profile=new Profile(identity);
  profile.setProperty(Profile.FIRST_NAME,"String_Node_Str");
  profile.setProperty(Profile.LAST_NAME,"String_Node_Str");
  profile.setProperty(Profile.FULL_NAME,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  identityStorage.saveProfile(profile);
  identity.setProfile(profile);
  tearDownIdentityList.add(identity);
  final ProfileFilter filter=new ProfileFilter();
  filter.setName("String_Node_Str");
  final List<Identity> result=identityStorage.getIdentitiesByProfileFilter(providerId,filter,0,1,false);
  assertEquals(0,result.size());
}
Program: 102510
Project: 102510
Buggy source:
/** 
 * Test   {@link org.exoplatform.social.core.storage.api.RelationshipStorage#getConnectionsCountByFilter(providerId,Identity,ProfileFilter)}
 * @throws Exception
 * @since 1.2.2
 */
@MaxQueryNumber(700) public void testGetConnectionsCountByFilter() throws Exception {
  populateData();
  populateRelationshipData(Type.CONFIRMED);
  ProfileFilter pf=new ProfileFilter();
  pf=buildProfileFilterWithExcludeIdentities(pf);
  int countIdentities=relationshipStorage.getConnectionsCountByFilter(tearDownIdentityList.get(0),pf);
  assertEquals("String_Node_Str",8,countIdentities);
  pf.setPosition("String_Node_Str");
  pf.setName("String_Node_Str");
  countIdentities=relationshipStorage.getConnectionsCountByFilter(tearDownIdentityList.get(0),pf);
  assertEquals("String_Node_Str",1,countIdentities);
}

Fixed version (ground truth):
/** 
 * Test   {@link org.exoplatform.social.core.storage.api.RelationshipStorage#getConnectionsCountByFilter(providerId,Identity,ProfileFilter)}
 * @throws Exception
 * @since 1.2.2
 */
@MaxQueryNumber(710) public void testGetConnectionsCountByFilter() throws Exception {
  populateData();
  populateRelationshipData(Type.CONFIRMED);
  ProfileFilter pf=new ProfileFilter();
  pf=buildProfileFilterWithExcludeIdentities(pf);
  int countIdentities=relationshipStorage.getConnectionsCountByFilter(tearDownIdentityList.get(0),pf);
  assertEquals("String_Node_Str",8,countIdentities);
  pf.setPosition("String_Node_Str");
  pf.setName("String_Node_Str");
  countIdentities=relationshipStorage.getConnectionsCountByFilter(tearDownIdentityList.get(0),pf);
  assertEquals("String_Node_Str",1,countIdentities);
}
Program: 102511
Project: 102511
Buggy source:
/** 
 * Test   {@link org.exoplatform.social.core.storage.api.RelationshipStorage#getConnectionsByFilter(providerId,Identity,ProfileFilter)}in case Identity had no connection yet
 * @throws Exception
 */
@MaxQueryNumber(550) public void testGetConnectionsByFilterEmpty() throws Exception {
  populateData();
  ProfileFilter pf=new ProfileFilter();
  pf=buildProfileFilterWithExcludeIdentities(pf);
  List<Identity> identities=relationshipStorage.getConnectionsByFilter(tearDownIdentityList.get(0),pf,0,20);
  assertEquals("String_Node_Str" + identities.size(),0,identities.size());
}

Fixed version (ground truth):
/** 
 * Test   {@link org.exoplatform.social.core.storage.api.RelationshipStorage#getConnectionsByFilter(providerId,Identity,ProfileFilter)}in case Identity had no connection yet
 * @throws Exception
 */
@MaxQueryNumber(570) public void testGetConnectionsByFilterEmpty() throws Exception {
  populateData();
  ProfileFilter pf=new ProfileFilter();
  pf=buildProfileFilterWithExcludeIdentities(pf);
  List<Identity> identities=relationshipStorage.getConnectionsByFilter(tearDownIdentityList.get(0),pf,0,20);
  assertEquals("String_Node_Str" + identities.size(),0,identities.size());
}
Program: 102512
Project: 102512
Buggy source:
/** 
 * Test   {@link org.exoplatform.social.core.storage.api.RelationshipStorage#getIncomingRelationshipsCount(Identity)}
 * @throws Exception
 * @since 1.2.0-Beta3
 */
@MaxQueryNumber(60) public void testGetIncomingRelationshipsCount() throws Exception {
  Relationship rootToJohnRelationship=new Relationship(rootIdentity,johnIdentity,Type.PENDING);
  rootToJohnRelationship=relationshipStorage.saveRelationship(rootToJohnRelationship);
  assertNotNull("String_Node_Str",rootToJohnRelationship.getId());
  Relationship maryToJohnRelationship=new Relationship(maryIdentity,johnIdentity,Type.PENDING);
  maryToJohnRelationship=relationshipStorage.saveRelationship(maryToJohnRelationship);
  assertNotNull("String_Node_Str",maryToJohnRelationship.getId());
  Relationship demoToJohnRelationship=new Relationship(demoIdentity,johnIdentity,Type.CONFIRMED);
  demoToJohnRelationship=relationshipStorage.saveRelationship(demoToJohnRelationship);
  assertNotNull("String_Node_Str",demoToJohnRelationship.getId());
  List<Identity> listIdentities=relationshipStorage.getIncomingRelationships(johnIdentity,0,10);
  assertNotNull("String_Node_Str",listIdentities);
  assertEquals("String_Node_Str",2,listIdentities.size());
  int count=relationshipStorage.getIncomingRelationshipsCount(johnIdentity);
  assertEquals("String_Node_Str",2,count);
  tearDownRelationshipList.add(rootToJohnRelationship);
  tearDownRelationshipList.add(maryToJohnRelationship);
  tearDownRelationshipList.add(demoToJohnRelationship);
}

Fixed version (ground truth):
/** 
 * Test   {@link org.exoplatform.social.core.storage.api.RelationshipStorage#getIncomingRelationshipsCount(Identity)}
 * @throws Exception
 * @since 1.2.0-Beta3
 */
@MaxQueryNumber(70) public void testGetIncomingRelationshipsCount() throws Exception {
  Relationship rootToJohnRelationship=new Relationship(rootIdentity,johnIdentity,Type.PENDING);
  rootToJohnRelationship=relationshipStorage.saveRelationship(rootToJohnRelationship);
  assertNotNull("String_Node_Str",rootToJohnRelationship.getId());
  Relationship maryToJohnRelationship=new Relationship(maryIdentity,johnIdentity,Type.PENDING);
  maryToJohnRelationship=relationshipStorage.saveRelationship(maryToJohnRelationship);
  assertNotNull("String_Node_Str",maryToJohnRelationship.getId());
  Relationship demoToJohnRelationship=new Relationship(demoIdentity,johnIdentity,Type.CONFIRMED);
  demoToJohnRelationship=relationshipStorage.saveRelationship(demoToJohnRelationship);
  assertNotNull("String_Node_Str",demoToJohnRelationship.getId());
  List<Identity> listIdentities=relationshipStorage.getIncomingRelationships(johnIdentity,0,10);
  assertNotNull("String_Node_Str",listIdentities);
  assertEquals("String_Node_Str",2,listIdentities.size());
  int count=relationshipStorage.getIncomingRelationshipsCount(johnIdentity);
  assertEquals("String_Node_Str",2,count);
  tearDownRelationshipList.add(rootToJohnRelationship);
  tearDownRelationshipList.add(maryToJohnRelationship);
  tearDownRelationshipList.add(demoToJohnRelationship);
}