From cf4edfcb4bc7d0d02cefa861a95812315f092a66 Mon Sep 17 00:00:00 2001 From: Szymon Szukalski Date: Thu, 25 Jul 2024 20:54:41 +1000 Subject: Removed unused variables and switch to constructor injection --- src/main/java/com/stileeducation/markr/service/TestService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/stileeducation/markr/service/TestService.java') diff --git a/src/main/java/com/stileeducation/markr/service/TestService.java b/src/main/java/com/stileeducation/markr/service/TestService.java index f3231b9..0478c3a 100644 --- a/src/main/java/com/stileeducation/markr/service/TestService.java +++ b/src/main/java/com/stileeducation/markr/service/TestService.java @@ -2,7 +2,6 @@ package com.stileeducation.markr.service; import com.stileeducation.markr.entity.Test; import com.stileeducation.markr.repository.TestRepository; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Optional; @@ -10,9 +9,13 @@ import java.util.Optional; @Service public class TestService { - @Autowired + final TestRepository testRepository; + public TestService(TestRepository testRepository) { + this.testRepository = testRepository; + } + public Test findOrCreateTest(String testId, Integer marksAvailable) { Optional optionalTest = testRepository.findByTestId(testId); if (optionalTest.isPresent()) { -- cgit v1.2.3