import net.pterodactylus.sone.core.SoneInserter.*
import net.pterodactylus.sone.core.event.*
import net.pterodactylus.sone.data.*
import net.pterodactylus.sone.core.SoneInserter.*
import net.pterodactylus.sone.core.event.*
import net.pterodactylus.sone.data.*
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.test.*
import org.hamcrest.MatcherAssert.*
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.test.*
import org.hamcrest.MatcherAssert.*
whenever(sone.fingerprint).thenReturn(fingerprint)
whenever(sone.rootAlbum).thenReturn(mock())
whenever(core.getSone(anyString())).thenReturn(sone)
whenever(sone.fingerprint).thenReturn(fingerprint)
whenever(sone.rootAlbum).thenReturn(mock())
whenever(core.getSone(anyString())).thenReturn(sone)
val finalUri = mock<FreenetURI>()
val sone = createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
val finalUri = mock<FreenetURI>()
val sone = createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
- whenever(freenetInterface.insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenReturn(finalUri)
+ whenever(freenetInterface.insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenReturn(finalUri)
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
doAnswer {
soneInserter.stop()
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
doAnswer {
soneInserter.stop()
}.whenever(core).touchConfiguration()
soneInserter.serviceRun()
val soneEvents = ArgumentCaptor.forClass(SoneEvent::class.java)
}.whenever(core).touchConfiguration()
soneInserter.serviceRun()
val soneEvents = ArgumentCaptor.forClass(SoneEvent::class.java)
- verify(freenetInterface).insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))
+ verify(freenetInterface).insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))
verify(eventBus, times(2)).post(soneEvents.capture())
assertThat(soneEvents.allValues[0], instanceOf(SoneInsertingEvent::class.java))
assertThat(soneEvents.allValues[0].sone, equalTo(sone))
verify(eventBus, times(2)).post(soneEvents.capture())
assertThat(soneEvents.allValues[0], instanceOf(SoneInsertingEvent::class.java))
assertThat(soneEvents.allValues[0].sone, equalTo(sone))
val finalUri = mock<FreenetURI>()
val sone = createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
val finalUri = mock<FreenetURI>()
val sone = createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
- whenever(freenetInterface.insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenAnswer {
+ whenever(freenetInterface.insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenAnswer {
- verify(freenetInterface).insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))
+ verify(freenetInterface).insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))
verify(eventBus, times(2)).post(soneEvents.capture())
assertThat(soneEvents.allValues[0], instanceOf(SoneInsertingEvent::class.java))
assertThat(soneEvents.allValues[0].sone, equalTo(sone))
verify(eventBus, times(2)).post(soneEvents.capture())
assertThat(soneEvents.allValues[0], instanceOf(SoneInsertingEvent::class.java))
assertThat(soneEvents.allValues[0].sone, equalTo(sone))
createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
- verify(freenetInterface, never()).insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))
+ verify(freenetInterface, never()).insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))
verify(eventBus, never()).post(argThat(org.hamcrest.Matchers.any(SoneEvent::class.java)))
}
@Test
fun `sone inserter posts aborted event if an exception occurs`() {
verify(eventBus, never()).post(argThat(org.hamcrest.Matchers.any(SoneEvent::class.java)))
}
@Test
fun `sone inserter posts aborted event if an exception occurs`() {
val sone = createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
val soneException = SoneException(Exception())
val sone = createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
val soneException = SoneException(Exception())
- whenever(freenetInterface.insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenAnswer {
+ whenever(freenetInterface.insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenAnswer {
- verify(freenetInterface).insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))
+ verify(freenetInterface).insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))
verify(eventBus, times(2)).post(soneEvents.capture())
assertThat(soneEvents.allValues[0], instanceOf(SoneInsertingEvent::class.java))
assertThat(soneEvents.allValues[0].sone, equalTo(sone))
verify(eventBus, times(2)).post(soneEvents.capture())
assertThat(soneEvents.allValues[0], instanceOf(SoneInsertingEvent::class.java))
assertThat(soneEvents.allValues[0].sone, equalTo(sone))
val finalUri = mock<FreenetURI>()
createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
val finalUri = mock<FreenetURI>()
createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
- whenever(freenetInterface.insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenReturn(finalUri)
+ whenever(freenetInterface.insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenReturn(finalUri)
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry,"SoneId", soneModificationDetector, 1)
doAnswer {
soneInserter.stop()
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry,"SoneId", soneModificationDetector, 1)
doAnswer {
soneInserter.stop()
createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
createSone(insertUri)
val soneModificationDetector = mock<SoneModificationDetector>()
whenever(soneModificationDetector.isEligibleForInsert).thenReturn(true)
val soneInserter = SoneInserter(core, eventBus, freenetInterface, metricRegistry, "SoneId", soneModificationDetector, 1)
- whenever(freenetInterface.insertDirectory(eq(insertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenAnswer {
+ whenever(freenetInterface.insertDirectory(eq(expectedInsertUri), any<HashMap<String, Any>>(), eq("index.html"))).thenAnswer {