import java.io.IOException;
import java.util.Collection;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.impl.IdOnlySone;
import net.pterodactylus.sone.database.PostProvider;
import net.pterodactylus.sone.database.SoneProvider;
-import com.google.common.base.Function;
import com.google.common.base.Optional;
+import kotlin.jvm.functions.Function1;
import org.junit.Test;
/**
}
@Test
+ public void invalidSskAndUskLinkIsParsedAsText() {
+ Iterable<Part> parts = soneTextParser.parse("SSK@a USK@a", null);
+ assertThat("Part Text", convertText(parts), is("SSK@a USK@a"));
+ }
+
+ @Test
public void sskLinkWithoutContextIsNotTrusted() {
Iterable<Part> parts = soneTextParser.parse("SSK@qM1nmgU-YUnIttmEhqjTl7ifAF3Z6o~5EPwQW03uEQU,aztSUkT-VT1dWvfSUt9YpfyW~Flmf5yXpBnIE~v8sAg,AAMC--8/test", null);
assertThat("Part Text", convertText(parts), is("[SSK@qM1nmgU-YUnIttmEhqjTl7ifAF3Z6o~5EPwQW03uEQU,aztSUkT-VT1dWvfSUt9YpfyW~Flmf5yXpBnIE~v8sAg,AAMC--8/test|SSK@qM1nmgU-YUnIttmEhqjTl7ifAF3Z6o~5EPwQW03uEQU,aztSUkT-VT1dWvfSUt9YpfyW~Flmf5yXpBnIE~v8sAg,AAMC--8/test|test]"));
*/
private static class TestSoneProvider implements SoneProvider {
+ @Nonnull
@Override
- public Function<String, Optional<Sone>> soneLoader() {
- return new Function<String, Optional<Sone>>() {
+ public Function1<String, Sone> getSoneLoader() {
+ return new Function1<String, Sone>() {
@Override
- public Optional<Sone> apply(String soneId) {
+ public Sone invoke(String soneId) {
return getSone(soneId);
}
};
}
- /**
- * {@inheritDoc}
- */
+ @Nullable
@Override
- public Optional<Sone> getSone(final String soneId) {
- return Optional.<Sone>of(new IdOnlySone(soneId));
+ public Sone getSone(final String soneId) {
+ return new IdOnlySone(soneId);
}
/**
private static class AbsentSoneProvider extends TestSoneProvider {
@Override
- public Optional<Sone> getSone(String soneId) {
- return Optional.absent();
+ public Sone getSone(String soneId) {
+ return null;
}
}
private static class TestPostProvider implements PostProvider {
+ @Nullable
@Override
- public Optional<Post> getPost(final String postId) {
- return Optional.<Post>of(new Post() {
+ public Post getPost(@Nonnull final String postId) {
+ return new Post() {
@Override
public String getId() {
return postId;
public Post setKnown(boolean known) {
return null;
}
- });
+ };
}
@Override
private static class AbsentPostProvider extends TestPostProvider {
+ @Nullable
@Override
- public Optional<Post> getPost(String postId) {
- return Optional.absent();
+ public Post getPost(@Nonnull String postId) {
+ return null;
}
}