package net.pterodactylus.sone.core;
import static com.google.common.io.ByteStreams.toByteArray;
-import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
+import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.lang.System.currentTimeMillis;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
@Test
public void insertionDelayIsForwardedToSoneInserter() {
- EventBus eventBus = new AsyncEventBus(sameThreadExecutor());
+ EventBus eventBus = new AsyncEventBus(directExecutor());
eventBus.register(new SoneInserter(core, eventBus, freenetInterface, "SoneId"));
eventBus.post(new InsertionDelayChangedEvent(15));
assertThat(SoneInserter.getInsertionDelay().get(), is(15));
verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html"));
verify(eventBus, times(2)).post(soneEvents.capture());
assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class));
- assertThat(soneEvents.getAllValues().get(0).sone(), is(sone));
+ assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone));
assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertedEvent.class));
- assertThat(soneEvents.getAllValues().get(1).sone(), is(sone));
+ assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone));
}
@Test
verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html"));
verify(eventBus, times(2)).post(soneEvents.capture());
assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class));
- assertThat(soneEvents.getAllValues().get(0).sone(), is(sone));
+ assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone));
assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertedEvent.class));
- assertThat(soneEvents.getAllValues().get(1).sone(), is(sone));
+ assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone));
verify(core, never()).touchConfiguration();
}
verify(freenetInterface).insertDirectory(eq(insertUri), any(HashMap.class), eq("index.html"));
verify(eventBus, times(2)).post(soneEvents.capture());
assertThat(soneEvents.getAllValues().get(0), instanceOf(SoneInsertingEvent.class));
- assertThat(soneEvents.getAllValues().get(0).sone(), is(sone));
+ assertThat(soneEvents.getAllValues().get(0).getSone(), is(sone));
assertThat(soneEvents.getAllValues().get(1), instanceOf(SoneInsertAbortedEvent.class));
- assertThat(soneEvents.getAllValues().get(1).sone(), is(sone));
+ assertThat(soneEvents.getAllValues().get(1).getSone(), is(sone));
verify(core, never()).touchConfiguration();
}