From c459e7d5abd66d7bcf38e151aa2632fcb139f4f5 Mon Sep 17 00:00:00 2001 From: Szymon Szukalski Date: Wed, 24 Jul 2024 17:31:54 +1000 Subject: Use Apache Commons Math for calculations and implement service tests Implement TestResultService tests and supporting entity builders. Switch to Apache Commons Math library for descriptive statistics. --- .../com/stileeducation/markr/util/TestBuilder.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/test/java/com/stileeducation/markr/util/TestBuilder.java (limited to 'src/test/java/com/stileeducation/markr/util/TestBuilder.java') diff --git a/src/test/java/com/stileeducation/markr/util/TestBuilder.java b/src/test/java/com/stileeducation/markr/util/TestBuilder.java new file mode 100644 index 0000000..5c513f3 --- /dev/null +++ b/src/test/java/com/stileeducation/markr/util/TestBuilder.java @@ -0,0 +1,43 @@ +package com.stileeducation.markr.util; + +import com.stileeducation.markr.entity.Test; +import com.stileeducation.markr.entity.TestResult; + +import java.util.HashSet; +import java.util.Set; + +public class TestBuilder { + private Long id; + private String testId; + private Integer marksAvailable; + private Set testResults = new HashSet<>(); + + public TestBuilder withId(Long id) { + this.id = id; + return this; + } + + public TestBuilder withTestId(String testId) { + this.testId = testId; + return this; + } + + public TestBuilder withMarksAvailable(Integer marksAvailable) { + this.marksAvailable = marksAvailable; + return this; + } + + public TestBuilder withTestResults(Set testResults) { + this.testResults = testResults; + return this; + } + + public Test build() { + Test test = new Test(); + test.setId(id); + test.setTestId(testId); + test.setMarksAvailable(marksAvailable); + test.setTestResults(testResults); + return test; + } +} -- cgit v1.2.3