Program: 69695
Project: 69695
Buggy source:
@Test public void testPostCalendarEvents() throws IOException, URISyntaxException {
  RestConnection conn=new RestConnection();
  assertTrue(conn.login(id2.getName(),"String_Node_Str"));
  URI calUri=UriBuilder.fromUri(getContextURI()).path("String_Node_Str").path(id2.getKey().toString()).path("String_Node_Str").build();
  HttpGet calMethod=conn.createGet(calUri,MediaType.APPLICATION_JSON,true);
  HttpResponse response=conn.execute(calMethod);
  assertEquals(200,response.getStatusLine().getStatusCode());
  List<CalendarVO> vos=parseArray(response);
  assertTrue(vos != null && !vos.isEmpty());
  CalendarVO calendar=getCourseCalendar(vos,course2);
  Assert.assertNotNull(calendar);
  EventVO event=new EventVO();
  Calendar cal=Calendar.getInstance();
  event.setBegin(cal.getTime());
  cal.add(Calendar.HOUR_OF_DAY,1);
  event.setEnd(cal.getTime());
  String subject=UUID.randomUUID().toString();
  event.setSubject(subject);
  URI eventUri=UriBuilder.fromUri(getContextURI()).path("String_Node_Str").path(id2.getKey().toString()).path("String_Node_Str").path(calendar.getId()).path("String_Node_Str").build();
  HttpPost postEventMethod=conn.createPost(eventUri,MediaType.APPLICATION_JSON,true);
  conn.addJsonEntity(postEventMethod,event);
  HttpResponse postEventResponse=conn.execute(postEventMethod);
  assertEquals(200,postEventResponse.getStatusLine().getStatusCode());
  EventVO newEvent=conn.parse(postEventResponse,EventVO.class);
  Assert.assertNotNull(newEvent);
  CalendarManager calendarManager=CalendarManagerFactory.getInstance().getCalendarManager();
  KalendarRenderWrapper calendarWrapper=calendarManager.getCourseCalendar(course2);
  Collection<KalendarEvent> savedEvents=calendarWrapper.getKalendar().getEvents();
  boolean found=false;
  for (  KalendarEvent savedEvent : savedEvents) {
    if (subject.equals(savedEvent.getSubject())) {
      found=true;
    }
  }
  Assert.assertTrue(found);
  conn.shutdown();
}

Fixed version (ground truth):
@Test public void testPostCalendarEvents() throws IOException, URISyntaxException {
  RestConnection conn=new RestConnection();
  assertTrue(conn.login(id2.getName(),"String_Node_Str"));
  URI calUri=UriBuilder.fromUri(getContextURI()).path("String_Node_Str").path(id2.getKey().toString()).path("String_Node_Str").build();
  HttpGet calMethod=conn.createGet(calUri,MediaType.APPLICATION_JSON,true);
  HttpResponse response=conn.execute(calMethod);
  assertEquals(200,response.getStatusLine().getStatusCode());
  List<CalendarVO> vos=parseArray(response);
  assertTrue(vos != null && !vos.isEmpty());
  CalendarVO calendar=getCourseCalendar(vos,course2);
  Assert.assertNotNull(calendar);
  EventVO event=new EventVO();
  Calendar cal=Calendar.getInstance();
  event.setBegin(cal.getTime());
  cal.add(Calendar.HOUR_OF_DAY,1);
  event.setEnd(cal.getTime());
  String subject=UUID.randomUUID().toString();
  event.setSubject(subject);
  URI eventUri=UriBuilder.fromUri(getContextURI()).path("String_Node_Str").path(id2.getKey().toString()).path("String_Node_Str").path(calendar.getId()).path("String_Node_Str").build();
  HttpPost postEventMethod=conn.createPost(eventUri,MediaType.APPLICATION_JSON);
  conn.addJsonEntity(postEventMethod,event);
  HttpResponse postEventResponse=conn.execute(postEventMethod);
  assertEquals(200,postEventResponse.getStatusLine().getStatusCode());
  EventVO newEvent=conn.parse(postEventResponse,EventVO.class);
  Assert.assertNotNull(newEvent);
  CalendarManager calendarManager=CalendarManagerFactory.getInstance().getCalendarManager();
  KalendarRenderWrapper calendarWrapper=calendarManager.getCourseCalendar(course2);
  Collection<KalendarEvent> savedEvents=calendarWrapper.getKalendar().getEvents();
  boolean found=false;
  for (  KalendarEvent savedEvent : savedEvents) {
    if (subject.equals(savedEvent.getSubject())) {
      found=true;
    }
  }
  Assert.assertTrue(found);
  conn.shutdown();
}