Added linting to build.

This commit is contained in:
neviyn 2018-10-09 16:43:32 +01:00
parent 185f258b6f
commit a52da46f52
4 changed files with 34 additions and 25 deletions

View File

@ -161,6 +161,20 @@
</dependency>
</dependencies>
</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>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>

View File

@ -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)
}
}

View File

@ -18,5 +18,4 @@ class ObservationDatabaseApplicationTests {
fun contextLoads() {
assertNotNull(controller)
}
}

View File

@ -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))