mirror of
				https://github.com/MinimalBible/MinimalBible
				synced 2025-11-03 18:10:27 -05:00 
			
		
		
		
	MBIndexManager fully tested
This commit is contained in:
		@ -12,6 +12,7 @@ import com.jayway.awaitility.Awaitility
 | 
				
			|||||||
import java.util.concurrent.TimeUnit
 | 
					import java.util.concurrent.TimeUnit
 | 
				
			||||||
import kotlin.test.assertTrue
 | 
					import kotlin.test.assertTrue
 | 
				
			||||||
import kotlin.test.assertFalse
 | 
					import kotlin.test.assertFalse
 | 
				
			||||||
 | 
					import kotlin.test.fail
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Created by bspeice on 2/16/15.
 | 
					 * Created by bspeice on 2/16/15.
 | 
				
			||||||
@ -107,11 +108,23 @@ class MBIndexManagerSpek() : Spek() {{
 | 
				
			|||||||
                assertTrue(indexManager indexReady book)
 | 
					                assertTrue(indexManager indexReady book)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        on("attempting to index anyway") {
 | 
				
			||||||
 | 
					            it("should throw an error") {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    indexManager buildIndex book
 | 
				
			||||||
 | 
					                    fail()
 | 
				
			||||||
 | 
					                } catch (e: IllegalStateException) {
 | 
				
			||||||
 | 
					                    // Intentionally empty body
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    given("a Book with an indexing error") {
 | 
					    given("a Book with an indexing error") {
 | 
				
			||||||
        val mocks = Mocks()
 | 
					        val mocks = Mocks()
 | 
				
			||||||
        val book = mocks.mockBook
 | 
					        val book = mocks.mockBook
 | 
				
			||||||
 | 
					        val mockIndex = mocks.mockIndex
 | 
				
			||||||
        val indexManager = mocks.indexManager
 | 
					        val indexManager = mocks.indexManager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Mockito.`when`(book.getIndexStatus())
 | 
					        Mockito.`when`(book.getIndexStatus())
 | 
				
			||||||
@ -128,9 +141,18 @@ class MBIndexManagerSpek() : Spek() {{
 | 
				
			|||||||
                assertFalse(indexManager indexReady book)
 | 
					                assertFalse(indexManager indexReady book)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        on("attempting to index") {
 | 
				
			||||||
 | 
					            indexManager buildIndex book
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            it("should run the index") {
 | 
				
			||||||
 | 
					                Mockito.verify(mockIndex, Mockito.times(1))
 | 
				
			||||||
 | 
					                        .scheduleIndexCreation(book);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    given("a Book in progress of being indexed") {
 | 
					    given("a Book in process of being indexed") {
 | 
				
			||||||
        val mocks = Mocks()
 | 
					        val mocks = Mocks()
 | 
				
			||||||
        val book = mocks.mockBook
 | 
					        val book = mocks.mockBook
 | 
				
			||||||
        val indexManager = mocks.indexManager
 | 
					        val indexManager = mocks.indexManager
 | 
				
			||||||
@ -149,6 +171,17 @@ class MBIndexManagerSpek() : Spek() {{
 | 
				
			|||||||
                assertFalse(indexManager shouldIndex book)
 | 
					                assertFalse(indexManager shouldIndex book)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        on("attempting to index anyway") {
 | 
				
			||||||
 | 
					            it("should throw an error to let us know it will not index") {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    indexManager buildIndex book
 | 
				
			||||||
 | 
					                    fail()
 | 
				
			||||||
 | 
					                } catch (e: IllegalStateException) {
 | 
				
			||||||
 | 
					                    // Intentionally empty body
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user