I'm trying to create 24 appointments per day and after the 24th appointment has been created, I want my script to switch to the next day and then continue adding appointments hour by hour and so on.
1 appointment = 1 hour
I'm using the following BeanShell PreProcessor piece of code for hour and day iteration inside the request:
cal.add(Calendar.DAY_OF_YEAR,1);
cal.add(Calendar.HOUR_OF_DAY,1);
I used User Defined Variables to set initial hour and date in the following format (HH:mm) (MM/dd/yyyy)
The script is working but it is only adding 1 appointment per day and then switches to the next day.
I can also use a loop controller and put the +1hour BeanShell PreProcessor request under the loop controller but then I got no clue how to switch the day after the 24 loops of the loop controller have been reached. Is there a way to iterate the days by 1 from the User Defined Variables on each thread execution?
This is the code that I used in the BeanShell inside my add appointment request:
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
Date date1 = sdf.parse(vars.get("HOUR"));
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
cal.add(Calendar.HOUR_OF_DAY,1);
date1 = cal.getTime();
vars.put("HOUR",sdf.format(date1));
log.info("HOUR=" + vars.get("HOUR"));
Mainly, I'm having a thread group with 3 requests which together are representing a flow: Login -> Create a patient -> Add appointment for the above patient
Add appointment is a POST request with a bunch of parameters. The ones I'm interested in iterating are: Appointment.StartDateDay and Appointment.StartTime.
please help ^^