From 39e7e3344bf0827fe9563dc1f08d18084316fd6f Mon Sep 17 00:00:00 2001 From: Szymon Szukalski Date: Fri, 26 Jul 2024 14:46:26 +1000 Subject: Simplify entity model builders --- .../java/com/stileeducation/markr/util/StudentBuilder.java | 12 +----------- src/test/java/com/stileeducation/markr/util/TestBuilder.java | 11 ----------- .../com/stileeducation/markr/util/TestResultBuilder.java | 8 ++++---- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/test/java/com/stileeducation/markr/util/StudentBuilder.java b/src/test/java/com/stileeducation/markr/util/StudentBuilder.java index 5189f19..897d84a 100644 --- a/src/test/java/com/stileeducation/markr/util/StudentBuilder.java +++ b/src/test/java/com/stileeducation/markr/util/StudentBuilder.java @@ -1,17 +1,13 @@ package com.stileeducation.markr.util; import com.stileeducation.markr.entity.Student; -import com.stileeducation.markr.entity.TestResult; - -import java.util.HashSet; -import java.util.Set; public class StudentBuilder { private Long id; private String firstName; private String lastName; private String studentNumber; - private Set testResults = new HashSet<>(); + public StudentBuilder withId(Long id) { this.id = id; @@ -33,18 +29,12 @@ public class StudentBuilder { return this; } - public StudentBuilder withTestResults(Set testResults) { - this.testResults = testResults; - return this; - } - public Student build() { Student student = new Student(); student.setId(id); student.setFirstName(firstName); student.setLastName(lastName); student.setStudentNumber(studentNumber); - student.setTestResults(testResults); return student; } } \ No newline at end of file diff --git a/src/test/java/com/stileeducation/markr/util/TestBuilder.java b/src/test/java/com/stileeducation/markr/util/TestBuilder.java index 5c513f3..e247f67 100644 --- a/src/test/java/com/stileeducation/markr/util/TestBuilder.java +++ b/src/test/java/com/stileeducation/markr/util/TestBuilder.java @@ -1,16 +1,11 @@ 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; @@ -27,17 +22,11 @@ public class TestBuilder { 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; } } diff --git a/src/test/java/com/stileeducation/markr/util/TestResultBuilder.java b/src/test/java/com/stileeducation/markr/util/TestResultBuilder.java index db26e15..70fcecd 100644 --- a/src/test/java/com/stileeducation/markr/util/TestResultBuilder.java +++ b/src/test/java/com/stileeducation/markr/util/TestResultBuilder.java @@ -8,7 +8,7 @@ public class TestResultBuilder { private Long id; private Student student; private Test test; - private Integer marksAwarded; + private Integer marksObtained; public TestResultBuilder withId(Long id) { this.id = id; @@ -25,12 +25,12 @@ public class TestResultBuilder { return this; } - public TestResultBuilder withMarksAwarded(Integer marksAwarded) { - this.marksAwarded = marksAwarded; + public TestResultBuilder withMarksObtained(Integer marksObtained) { + this.marksObtained = marksObtained; return this; } public TestResult build() { - return new TestResult(id, student, test, marksAwarded); + return new TestResult(id, student, test, marksObtained); } } \ No newline at end of file -- cgit v1.2.3