test: ap factory
This commit is contained in:
@@ -0,0 +1,76 @@
|
|||||||
|
package appointmentplanner;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
|
import appointmentplanner.api.AppointmentData;
|
||||||
|
import appointmentplanner.api.LocalDay;
|
||||||
|
import appointmentplanner.api.LocalDayPlan;
|
||||||
|
import appointmentplanner.api.TimePreference;
|
||||||
|
|
||||||
|
public class AppointmentFactoryTest {
|
||||||
|
|
||||||
|
private static APFactory factory = new APFactory();
|
||||||
|
|
||||||
|
static Stream<Arguments> localDayPlanProvider() {
|
||||||
|
return Stream.of(
|
||||||
|
Arguments.of(TestData.TODAY, Instant.parse("2025-10-13T08:00:00Z"), Instant.parse("2025-10-13T12:00:00Z")),
|
||||||
|
Arguments.of(TestData.TODAY, Instant.parse("2025-10-14T09:00:00Z"), Instant.parse("2025-10-14T11:00:00Z")),
|
||||||
|
Arguments.of(TestData.TODAY, Instant.parse("2025-10-15T10:00:00Z"), Instant.parse("2025-10-15T14:00:00Z")));
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ParameterizedTest
|
||||||
|
// @MethodSource("localDayPlanProvider")
|
||||||
|
void testCreateLocalDayPlan_shouldCreateSccessfully(LocalDay localDay, Instant start, Instant end) {
|
||||||
|
LocalDayPlan plan = factory.createLocalDayPlan(localDay, start, end);
|
||||||
|
|
||||||
|
assertThat(plan.day()).isEqualTo(localDay);
|
||||||
|
assertThat(plan.startOfDay()).isEqualTo(start);
|
||||||
|
assertThat(plan.endOfDay()).isEqualTo(end);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Stream<Arguments> appointmentDataProvider() {
|
||||||
|
return Stream.of(
|
||||||
|
Arguments.of("Meeting with team", TestData.D30),
|
||||||
|
Arguments.of("Doctor's appointment", TestData.D15),
|
||||||
|
Arguments.of("Project discussion", TestData.D90));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("appointmentDataProvider")
|
||||||
|
void testCreateAppintmentData_shouldCreateSuccessfully(String description, Duration duration) {
|
||||||
|
var appData = factory.createAppointmentData(description, duration);
|
||||||
|
|
||||||
|
assertThat(appData.description()).isEqualTo(description);
|
||||||
|
assertThat(appData.duration()).isEqualTo(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Stream<Arguments> appointmentRequestProvider() {
|
||||||
|
return Stream.of(
|
||||||
|
Arguments.of(factory.createAppointmentData("Meeting with team", TestData.D30), TestData.T09_00,
|
||||||
|
TimePreference.UNSPECIFIED),
|
||||||
|
Arguments.of(factory.createAppointmentData("Doctor's appointment", TestData.D15), TestData.T10_30,
|
||||||
|
TimePreference.EARLIEST),
|
||||||
|
Arguments.of(factory.createAppointmentData("Project discussion", TestData.D90), TestData.T16_00,
|
||||||
|
TimePreference.LATEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("appointmentRequestProvider")
|
||||||
|
void testCreateAppointmentRequest_shouldCreateSuccessfully(AppointmentData appData,
|
||||||
|
LocalTime prefStart, TimePreference timePref) {
|
||||||
|
var appRequest = factory.createAppointmentRequest(appData, prefStart, timePref);
|
||||||
|
|
||||||
|
assertThat(appRequest.appointmentData()).isEqualTo(appData);
|
||||||
|
assertThat(appRequest.startTime()).isEqualTo(prefStart);
|
||||||
|
assertThat(appRequest.timePreference()).isEqualTo(timePref);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user