Added linting to build.
This commit is contained in:
parent
185f258b6f
commit
a52da46f52
@ -161,6 +161,20 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.github.gantsign.maven</groupId>
|
||||||
|
<artifactId>ktlint-maven-plugin</artifactId>
|
||||||
|
<version>0.9.14</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>format-and-check</id>
|
||||||
|
<goals>
|
||||||
|
<goal>format</goal>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
|
@ -72,7 +72,7 @@ class ControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testGetAllTutors_NoTutors(){
|
fun testGetAllTutors_NoTutors() {
|
||||||
val result = controller.getAllTutors()
|
val result = controller.getAllTutors()
|
||||||
assertTrue(result.isEmpty())
|
assertTrue(result.isEmpty())
|
||||||
}
|
}
|
||||||
@ -133,15 +133,14 @@ class ControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testGetObservationsForTutor_NoTutor()
|
fun testGetObservationsForTutor_NoTutor() {
|
||||||
{
|
|
||||||
doReturn(Optional.ofNullable(null)).`when`(tutorRepository).findById(1)
|
doReturn(Optional.ofNullable(null)).`when`(tutorRepository).findById(1)
|
||||||
val result = controller.getObservationsForTutor(1)
|
val result = controller.getObservationsForTutor(1)
|
||||||
assertTrue(result.isEmpty())
|
assertTrue(result.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAddObservation(){
|
fun testAddObservation() {
|
||||||
val site = Site(1, "X")
|
val site = Site(1, "X")
|
||||||
val tutor = Tutor(1, "Foo Bar", site)
|
val tutor = Tutor(1, "Foo Bar", site)
|
||||||
doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
|
doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
|
||||||
@ -152,5 +151,4 @@ class ControllerTest {
|
|||||||
val result = controller.addObservation(newData)
|
val result = controller.addObservation(newData)
|
||||||
assertEquals(1L, result)
|
assertEquals(1L, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -18,5 +18,4 @@ class ObservationDatabaseApplicationTests {
|
|||||||
fun contextLoads() {
|
fun contextLoads() {
|
||||||
assertNotNull(controller)
|
assertNotNull(controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,9 @@ import org.springframework.test.context.junit4.SpringRunner
|
|||||||
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager
|
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RunWith(SpringRunner::class)
|
@RunWith(SpringRunner::class)
|
||||||
@DataJpaTest
|
@DataJpaTest
|
||||||
class RepositoryTest{
|
class RepositoryTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
lateinit var entityManager: TestEntityManager
|
lateinit var entityManager: TestEntityManager
|
||||||
@ -22,33 +20,33 @@ class RepositoryTest{
|
|||||||
lateinit var observationRepository: ObservationRepository
|
lateinit var observationRepository: ObservationRepository
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFindBySiteAndDateBetween_EmptyRepository(){
|
fun testFindBySiteAndDateBetween_EmptyRepository() {
|
||||||
val result = observationRepository.findBySiteAndDateBetween(Site(1, "x"), LocalDate.now(), LocalDate.now())
|
val result = observationRepository.findBySiteAndDateBetween(Site(1, "x"), LocalDate.now(), LocalDate.now())
|
||||||
assertTrue(result.isEmpty())
|
assertTrue(result.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFindBySiteAndWhomAndDateBetween_EmptyRepository(){
|
fun testFindBySiteAndWhomAndDateBetween_EmptyRepository() {
|
||||||
val result = observationRepository.findBySiteAndWhomAndDateBetween(Site(1, "x"), "none", LocalDate.now(), LocalDate.now())
|
val result = observationRepository.findBySiteAndWhomAndDateBetween(Site(1, "x"), "none", LocalDate.now(), LocalDate.now())
|
||||||
assertTrue(result.isEmpty())
|
assertTrue(result.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFindByTutorsAndDateBetween_EmptyRepository(){
|
fun testFindByTutorsAndDateBetween_EmptyRepository() {
|
||||||
val result = observationRepository.findByTutorsAndDateBetween(Tutor(1, "x", Site(1, "x")), LocalDate.now(), LocalDate.now())
|
val result = observationRepository.findByTutorsAndDateBetween(Tutor(1, "x", Site(1, "x")), LocalDate.now(), LocalDate.now())
|
||||||
assertTrue(result.isEmpty())
|
assertTrue(result.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFindByTutorsAndWhomAndDateBetween_EmptyRepository(){
|
fun testFindByTutorsAndWhomAndDateBetween_EmptyRepository() {
|
||||||
val result = observationRepository.findByTutorsAndWhomAndDateBetween(Tutor(1, "x", Site(1, "x")), "none", LocalDate.now(), LocalDate.now())
|
val result = observationRepository.findByTutorsAndWhomAndDateBetween(Tutor(1, "x", Site(1, "x")), "none", LocalDate.now(), LocalDate.now())
|
||||||
assertTrue(result.isEmpty())
|
assertTrue(result.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFindBySiteAndDateBetween(){
|
fun testFindBySiteAndDateBetween() {
|
||||||
val correctSite = entityManager.persist(Site(name = "Correct"))
|
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 tutor = entityManager.persist(Tutor(name = "X", site = correctSite))
|
||||||
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
|
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
|
||||||
val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5),
|
val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5),
|
||||||
@ -73,9 +71,9 @@ class RepositoryTest{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFindBySiteAndWhomAndDateBetween(){
|
fun testFindBySiteAndWhomAndDateBetween() {
|
||||||
val correctSite = entityManager.persist(Site(name = "Correct"))
|
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 tutor = entityManager.persist(Tutor(name = "X", site = correctSite))
|
||||||
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
|
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
|
||||||
val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5),
|
val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5),
|
||||||
@ -104,7 +102,7 @@ class RepositoryTest{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFindByTutorsAndDateBetween(){
|
fun testFindByTutorsAndDateBetween() {
|
||||||
val site = entityManager.persist(Site(name = "Correct"))
|
val site = entityManager.persist(Site(name = "Correct"))
|
||||||
val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
|
val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
|
||||||
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))
|
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))
|
||||||
@ -140,7 +138,7 @@ class RepositoryTest{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFindByTutorsAndWhomAndDateBetween(){
|
fun testFindByTutorsAndWhomAndDateBetween() {
|
||||||
val site = entityManager.persist(Site(name = "Correct"))
|
val site = entityManager.persist(Site(name = "Correct"))
|
||||||
val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
|
val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
|
||||||
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))
|
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))
|
||||||
|
Loading…
Reference in New Issue
Block a user