diff --git a/backend/pom.xml b/backend/pom.xml
index e9f8ab8..76bf745 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -161,6 +161,20 @@
+
+ com.github.gantsign.maven
+ ktlint-maven-plugin
+ 0.9.14
+
+
+ format-and-check
+
+ format
+ check
+
+
+
+
maven-resources-plugin
3.1.0
diff --git a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt
index 82150d7..de8cf7c 100644
--- a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt
+++ b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt
@@ -72,7 +72,7 @@ class ControllerTest {
}
@Test
- fun testGetAllTutors_NoTutors(){
+ fun testGetAllTutors_NoTutors() {
val result = controller.getAllTutors()
assertTrue(result.isEmpty())
}
@@ -133,15 +133,14 @@ class ControllerTest {
}
@Test
- fun testGetObservationsForTutor_NoTutor()
- {
+ fun testGetObservationsForTutor_NoTutor() {
doReturn(Optional.ofNullable(null)).`when`(tutorRepository).findById(1)
val result = controller.getObservationsForTutor(1)
assertTrue(result.isEmpty())
}
@Test
- fun testAddObservation(){
+ fun testAddObservation() {
val site = Site(1, "X")
val tutor = Tutor(1, "Foo Bar", site)
doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
@@ -152,5 +151,4 @@ class ControllerTest {
val result = controller.addObservation(newData)
assertEquals(1L, result)
}
-
}
\ No newline at end of file
diff --git a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ObservationDatabaseApplicationTests.kt b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ObservationDatabaseApplicationTests.kt
index 14822e1..291496b 100644
--- a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ObservationDatabaseApplicationTests.kt
+++ b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ObservationDatabaseApplicationTests.kt
@@ -11,12 +11,11 @@ import org.springframework.test.context.junit4.SpringRunner
@SpringBootTest
class ObservationDatabaseApplicationTests {
- @Autowired
- lateinit var controller: Controller
-
- @Test
- fun contextLoads() {
- assertNotNull(controller)
- }
+ @Autowired
+ lateinit var controller: Controller
+ @Test
+ fun contextLoads() {
+ assertNotNull(controller)
+ }
}
diff --git a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/RepositoryTest.kt b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/RepositoryTest.kt
index 9b2ea45..97e1acf 100644
--- a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/RepositoryTest.kt
+++ b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/RepositoryTest.kt
@@ -9,11 +9,9 @@ import org.springframework.test.context.junit4.SpringRunner
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager
import org.springframework.beans.factory.annotation.Autowired
-
-
@RunWith(SpringRunner::class)
@DataJpaTest
-class RepositoryTest{
+class RepositoryTest {
@Autowired
lateinit var entityManager: TestEntityManager
@@ -22,33 +20,33 @@ class RepositoryTest{
lateinit var observationRepository: ObservationRepository
@Test
- fun testFindBySiteAndDateBetween_EmptyRepository(){
+ fun testFindBySiteAndDateBetween_EmptyRepository() {
val result = observationRepository.findBySiteAndDateBetween(Site(1, "x"), LocalDate.now(), LocalDate.now())
assertTrue(result.isEmpty())
}
@Test
- fun testFindBySiteAndWhomAndDateBetween_EmptyRepository(){
+ fun testFindBySiteAndWhomAndDateBetween_EmptyRepository() {
val result = observationRepository.findBySiteAndWhomAndDateBetween(Site(1, "x"), "none", LocalDate.now(), LocalDate.now())
assertTrue(result.isEmpty())
}
@Test
- fun testFindByTutorsAndDateBetween_EmptyRepository(){
+ fun testFindByTutorsAndDateBetween_EmptyRepository() {
val result = observationRepository.findByTutorsAndDateBetween(Tutor(1, "x", Site(1, "x")), LocalDate.now(), LocalDate.now())
assertTrue(result.isEmpty())
}
@Test
- fun testFindByTutorsAndWhomAndDateBetween_EmptyRepository(){
+ fun testFindByTutorsAndWhomAndDateBetween_EmptyRepository() {
val result = observationRepository.findByTutorsAndWhomAndDateBetween(Tutor(1, "x", Site(1, "x")), "none", LocalDate.now(), LocalDate.now())
assertTrue(result.isEmpty())
}
@Test
- fun testFindBySiteAndDateBetween(){
+ fun testFindBySiteAndDateBetween() {
val correctSite = entityManager.persist(Site(name = "Correct"))
- val incorrectSite = entityManager.persist(Site(name="Incorrect"))
+ val incorrectSite = entityManager.persist(Site(name = "Incorrect"))
val tutor = entityManager.persist(Tutor(name = "X", site = correctSite))
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5),
@@ -73,9 +71,9 @@ class RepositoryTest{
}
@Test
- fun testFindBySiteAndWhomAndDateBetween(){
+ fun testFindBySiteAndWhomAndDateBetween() {
val correctSite = entityManager.persist(Site(name = "Correct"))
- val incorrectSite = entityManager.persist(Site(name="Incorrect"))
+ val incorrectSite = entityManager.persist(Site(name = "Incorrect"))
val tutor = entityManager.persist(Tutor(name = "X", site = correctSite))
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5),
@@ -104,7 +102,7 @@ class RepositoryTest{
}
@Test
- fun testFindByTutorsAndDateBetween(){
+ fun testFindByTutorsAndDateBetween() {
val site = entityManager.persist(Site(name = "Correct"))
val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))
@@ -140,7 +138,7 @@ class RepositoryTest{
}
@Test
- fun testFindByTutorsAndWhomAndDateBetween(){
+ fun testFindByTutorsAndWhomAndDateBetween() {
val site = entityManager.persist(Site(name = "Correct"))
val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))