return null;
}
- Sone sone = new DefaultSone(originalSone.getId(), originalSone.isLocal()).setIdentity(originalSone.getIdentity());
+ Sone sone = new DefaultSone(core.getDatabase(), originalSone.getId(), originalSone.isLocal()).setIdentity(originalSone.getIdentity());
SimpleXML soneXml;
try {
/*
- * Sone - Album.java - Copyright © 2011–2013 David Roden
+ * Sone - MemoryAlbum.java - Copyright © 2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
package net.pterodactylus.sone.data.impl;
-import static com.google.common.base.Optional.absent;
-import static com.google.common.base.Optional.fromNullable;
import static com.google.common.base.Preconditions.checkState;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.UUID;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.AlbumBuilder;
+import net.pterodactylus.sone.database.Database;
import net.pterodactylus.sone.database.ImageBuilder;
-import com.google.common.base.Function;
import com.google.common.base.Optional;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
/**
- * Dumb, store-everything-in-memory implementation of an {@link Album}.
+ * TODO
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultAlbum extends AbstractAlbum {
- /** The Sone this album belongs to. */
- private Sone sone;
+ private final Database database;
+ private final Sone sone; /* TODO - only store sone ID. */
+ private final String parentId;
- /** The parent album. */
- private final DefaultAlbum parent;
-
- /** Nested albums. */
- private final List<Album> albums = new ArrayList<Album>();
-
- /** The image IDs in order. */
- final List<String> imageIds = new ArrayList<String>();
-
- /** The images in this album. */
- final Map<String, Image> images = new HashMap<String, Image>();
-
- /** Creates a new album with a random ID. */
- public DefaultAlbum(Sone sone, DefaultAlbum parent) {
- this(UUID.randomUUID().toString(), sone, parent);
- }
-
- /**
- * Creates a new album with the given ID.
- *
- * @param id
- * The ID of the album
- */
- public DefaultAlbum(String id, Sone sone, DefaultAlbum parent) {
+ protected DefaultAlbum(Database database, String id, Sone sone, String parentId) {
super(id);
+ this.database = database;
this.sone = sone;
- this.parent = parent;
+ this.parentId = parentId;
}
- //
- // ACCESSORS
- //
-
@Override
public Sone getSone() {
return sone;
@Override
public List<Album> getAlbums() {
- return new ArrayList<Album>(albums);
+ return database.getAlbums(this);
}
@Override
public List<Image> getImages() {
- return new ArrayList<Image>(Collections2.filter(Collections2.transform(imageIds, new Function<String, Image>() {
-
- @Override
- @SuppressWarnings("synthetic-access")
- public Image apply(String imageId) {
- return images.get(imageId);
- }
- }), Predicates.notNull()));
+ return database.getImages(this);
}
@Override
public Optional<Image> getAlbumImage() {
- if (albumImage == null) {
- return absent();
- }
- return fromNullable(fromNullable(images.get(albumImage)).or(images.values().iterator().next()));
+ return database.getImage(albumImage);
}
@Override
public Album getParent() {
- return parent;
+ return database.getAlbum(parentId).get();
}
@Override
- public AlbumBuilder newAlbumBuilder() {
- return new DefaultAlbumBuilder(sone, this) {
+ public AlbumBuilder newAlbumBuilder() throws IllegalStateException {
+ return new AbstractAlbumBuilder() {
@Override
public Album build() throws IllegalStateException {
- Album album = super.build();
- albums.add(album);
- return album;
+ validate();
+ DefaultAlbum memoryAlbum = new DefaultAlbum(database, getId(), sone, DefaultAlbum.this.id);
+ database.storeAlbum(memoryAlbum);
+ return memoryAlbum;
}
};
}
@Override
public ImageBuilder newImageBuilder() throws IllegalStateException {
- return new DefaultImageBuilder(sone, this) {
+ return new AbstractImageBuilder() {
@Override
public Image build() throws IllegalStateException {
- Image image = super.build();
- if (images.isEmpty() && (albumImage == null)) {
- albumImage = image.getId();
- }
- images.put(image.getId(), image);
- imageIds.add(image.getId());
- return image;
+ validate();
+ DefaultImage memoryImage = new DefaultImage(database, getId(), sone, DefaultAlbum.this.id, key, getCreationTime(), width, height);
+ database.storeImage(memoryImage);
+ return memoryImage;
}
};
}
@Override
public void moveUp() {
- int oldIndex = parent.albums.indexOf(this);
- parent.albums.remove(this);
- parent.albums.add(Math.max(0, oldIndex - 1), this);
+ database.moveUp(this);
}
@Override
public void moveDown() {
- int oldIndex = parent.albums.indexOf(this);
- parent.albums.remove(this);
- parent.albums.add(Math.min(parent.albums.size(), oldIndex + 1), this);
+ database.moveDown(this);
}
@Override
public void remove() throws IllegalStateException {
checkState(!isRoot(), "can not remove root album");
- removeAllAlbums();
- removeAllImages();
- parent.albums.remove(this);
- }
-
- private void removeAllImages() {
- for (Image image : images.values()) {
- image.remove();
- }
- }
-
- private void removeAllAlbums() {
- for (Album album: albums) {
+ for (Album album : getAlbums()) {
album.remove();
}
+ for (Image image : getImages()) {
+ image.remove();
+ }
+ database.removeAlbum(this);
}
}
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.AlbumBuilder;
+import net.pterodactylus.sone.database.Database;
/**
- * {@link AlbumBuilder} implementation that creates {@link DefaultAlbum} objects.
+ * {@link AlbumBuilder} implementation that creates {@link DefaultAlbum}
+ * objects.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultAlbumBuilder extends AbstractAlbumBuilder {
+ private final Database database;
private final Sone sone;
- private final DefaultAlbum parent;
+ private final String parentId;
- public DefaultAlbumBuilder(Sone sone, DefaultAlbum parent) {
+ public DefaultAlbumBuilder(Database database, Sone sone, String parentId) {
+ this.database = database;
this.sone = sone;
- this.parent = parent;
+ this.parentId = parentId;
}
@Override
public Album build() throws IllegalStateException {
validate();
- return new DefaultAlbum(getId(), sone, parent);
+ DefaultAlbum album = new DefaultAlbum(database, getId(), sone, parentId);
+ if (parentId != null) {
+ database.storeAlbum(album);
+ }
+ return album;
}
}
/*
- * Sone - DefaultImage.java - Copyright © 2013 David Roden
+ * Sone - MemoryImage.java - Copyright © 2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
package net.pterodactylus.sone.data.impl;
-import static com.google.common.collect.FluentIterable.from;
-
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.database.Database;
/**
- * Dumb, store-everything-in-memory implementation of an {@link Image}.
+ * {@link Image} implementation that uses a {@link Database}.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultImage extends AbstractImage {
- private final Sone sone;
- private final DefaultAlbum album;
+ private final Database database;
+ private final Sone sone; /* TODO - store sone ID only. */
+ private final String albumId;
- public DefaultImage(String id, Sone sone, DefaultAlbum album, String key, long creationTime, int width, int height) {
+ public DefaultImage(Database database, String id, Sone sone, String albumId, String key, long creationTime, int width, int height) {
super(id, key, creationTime, width, height);
+ this.database = database;
this.sone = sone;
- this.album = album;
+ this.albumId = albumId;
}
@Override
@Override
public Album getAlbum() {
- return album;
+ return database.getAlbum(albumId).get();
}
@Override
public void moveUp() throws IllegalStateException {
- int oldIndex = album.imageIds.indexOf(getId());
- album.imageIds.remove(getId());
- album.imageIds.add(Math.max(0, oldIndex - 1), getId());
+ database.moveUp(this);
}
@Override
public void moveDown() throws IllegalStateException {
- int oldIndex = album.imageIds.indexOf(getId());
- album.imageIds.remove(getId());
- album.imageIds.add(Math.min(album.imageIds.size(), oldIndex + 1), getId());
+ database.moveDown(this);
}
@Override
public void remove() throws IllegalStateException {
- synchronized (album) {
- album.images.remove(getId());
- album.imageIds.remove(getId());
- if (getId().equals(album.albumImage)) {
- album.albumImage = from(album.images.values()).transform(GET_ID).first().orNull();
- }
- }
+ database.removeImage(this);
}
}
/*
- * Sone - ImageBuilderImpl.java - Copyright © 2013 David Roden
+ * Sone - MemoryImageBuilder.java - Copyright © 2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
package net.pterodactylus.sone.data.impl;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.ImageBuilder;
+import net.pterodactylus.sone.database.memory.MemoryDatabase;
/**
- * {@link ImageBuilder} implementation that creates {@link DefaultImage} objects.
+ * {@link ImageBuilder} implementation that creates {@link DefaultImage}s.
*
- * @author <a href="mailto:d.roden@xplosion.de">David Roden</a>
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultImageBuilder extends AbstractImageBuilder {
- protected final Sone sone;
- protected final DefaultAlbum album;
+ private final MemoryDatabase memoryDatabase;
+ private final Sone sone;
+ private final String albumId;
- public DefaultImageBuilder(Sone sone, DefaultAlbum album) {
- this.sone = checkNotNull(sone, "sone must not be null");
- this.album = checkNotNull(album, "album must not be null");
+ public DefaultImageBuilder(MemoryDatabase memoryDatabase, Sone sone, String albumId) {
+ this.memoryDatabase = memoryDatabase;
+ this.sone = sone;
+ this.albumId = albumId;
}
@Override
public Image build() throws IllegalStateException {
validate();
- return new DefaultImage(getId(), sone, album, key, getCreationTime(), width, height);
+ return new DefaultImage(memoryDatabase, getId(), sone, albumId, key, getCreationTime(), width, height);
}
}
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.AlbumBuilder;
+import net.pterodactylus.sone.database.Database;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.util.logging.Logging;
/** The logger. */
private static final Logger logger = Logging.getLogger(DefaultSone.class);
+ /** The database. */
+ private final Database database;
+
/** The ID of this Sone. */
private final String id;
private final Set<String> likedReplyIds = new CopyOnWriteArraySet<String>();
/** The root album containing all albums. */
- private final DefaultAlbum rootAlbum = new DefaultAlbum(this, null);
+ private final Album rootAlbum;
/** Sone-specific options. */
private Options options = new Options();
* @param local
* {@code true} if the Sone is a local Sone, {@code false} otherwise
*/
- public DefaultSone(String id, boolean local) {
+ public DefaultSone(Database database, String id, boolean local) {
+ this.database = database;
this.id = id;
this.local = local;
+ rootAlbum = new DefaultAlbumBuilder(database, this, null).randomId().build();
}
//
@Override
public AlbumBuilder newAlbumBuilder() {
- return new DefaultAlbumBuilder(this, rootAlbum);
+ return new DefaultAlbumBuilder(database, this, rootAlbum.getId());
}
//
+++ /dev/null
-/*
- * Sone - MemoryAlbum.java - Copyright © 2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database.memory;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import java.util.List;
-
-import net.pterodactylus.sone.data.Album;
-import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.data.impl.AbstractAlbum;
-import net.pterodactylus.sone.data.impl.AbstractAlbumBuilder;
-import net.pterodactylus.sone.data.impl.AbstractImageBuilder;
-import net.pterodactylus.sone.database.AlbumBuilder;
-import net.pterodactylus.sone.database.ImageBuilder;
-
-import com.google.common.base.Optional;
-
-/**
- * TODO
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class MemoryAlbum extends AbstractAlbum {
-
- private final MemoryDatabase memoryDatabase;
- private final Sone sone; /* TODO - only store sone ID. */
- private final String parentId;
-
- protected MemoryAlbum(MemoryDatabase memoryDatabase, String id, Sone sone, String parentId) {
- super(id);
- this.memoryDatabase = memoryDatabase;
- this.sone = sone;
- this.parentId = parentId;
- }
-
- @Override
- public Sone getSone() {
- return sone;
- }
-
- @Override
- public List<Album> getAlbums() {
- return memoryDatabase.getAlbums(this);
- }
-
- @Override
- public List<Image> getImages() {
- return memoryDatabase.getImages(this);
- }
-
- @Override
- public Optional<Image> getAlbumImage() {
- return memoryDatabase.getImage(albumImage);
- }
-
- @Override
- public Album getParent() {
- return memoryDatabase.getAlbum(parentId).get();
- }
-
- @Override
- public AlbumBuilder newAlbumBuilder() throws IllegalStateException {
- return new AbstractAlbumBuilder() {
- @Override
- public Album build() throws IllegalStateException {
- validate();
- MemoryAlbum memoryAlbum = new MemoryAlbum(memoryDatabase, getId(), sone, MemoryAlbum.this.id);
- memoryDatabase.storeAlbum(memoryAlbum);
- return memoryAlbum;
- }
- };
- }
-
- @Override
- public ImageBuilder newImageBuilder() throws IllegalStateException {
- return new AbstractImageBuilder() {
- @Override
- public Image build() throws IllegalStateException {
- validate();
- MemoryImage memoryImage = new MemoryImage(memoryDatabase, getId(), sone, MemoryAlbum.this.id, key, getCreationTime(), width, height);
- memoryDatabase.storeImage(memoryImage);
- return memoryImage;
- }
- };
- }
-
- @Override
- public void moveUp() {
- memoryDatabase.moveUp(this);
- }
-
- @Override
- public void moveDown() {
- memoryDatabase.moveDown(this);
- }
-
- @Override
- public void remove() throws IllegalStateException {
- checkState(!isRoot(), "can not remove root album");
- for (Album album : getAlbums()) {
- album.remove();
- }
- for (Image image : getImages()) {
- image.remove();
- }
- memoryDatabase.removeAlbum(this);
- }
-
-}
+++ /dev/null
-/*
- * Sone - MemoryImage.java - Copyright © 2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database.memory;
-
-import net.pterodactylus.sone.data.Album;
-import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.data.impl.AbstractImage;
-import net.pterodactylus.sone.database.Database;
-
-/**
- * In-memory implementation of an {@link Image}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class MemoryImage extends AbstractImage {
-
- private final Database database;
- private final Sone sone; /* TODO - store sone ID only. */
- private final String albumId;
-
- public MemoryImage(Database database, String id, Sone sone, String albumId, String key, long creationTime, int width, int height) {
- super(id, key, creationTime, width, height);
- this.database = database;
- this.sone = sone;
- this.albumId = albumId;
- }
-
- @Override
- public Sone getSone() {
- return sone;
- }
-
- @Override
- public Album getAlbum() {
- return database.getAlbum(albumId).get();
- }
-
- @Override
- public void moveUp() throws IllegalStateException {
- database.moveUp(this);
- }
-
- @Override
- public void moveDown() throws IllegalStateException {
- database.moveDown(this);
- }
-
- @Override
- public void remove() throws IllegalStateException {
- database.removeImage(this);
- }
-
-}
+++ /dev/null
-/*
- * Sone - MemoryImageBuilder.java - Copyright © 2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database.memory;
-
-import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.data.impl.AbstractImageBuilder;
-import net.pterodactylus.sone.database.ImageBuilder;
-
-/**
- * {@link ImageBuilder} implementation that creates {@link MemoryImage}s.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class MemoryImageBuilder extends AbstractImageBuilder {
-
- private final MemoryDatabase memoryDatabase;
- private final Sone sone;
- private final String albumId;
-
- public MemoryImageBuilder(MemoryDatabase memoryDatabase, Sone sone, String albumId) {
- this.memoryDatabase = memoryDatabase;
- this.sone = sone;
- this.albumId = albumId;
- }
-
- @Override
- public Image build() throws IllegalStateException {
- validate();
- return new MemoryImage(memoryDatabase, getId(), sone, albumId, key, getCreationTime(), width, height);
- }
-
-}
* The part to render
*/
private void render(Writer writer, PostPart postPart) {
- SoneTextParser parser = new SoneTextParser(core, core);
+ SoneTextParser parser = new SoneTextParser(core.getDatabase());
SoneTextParserContext parserContext = new SoneTextParserContext(null, postPart.getPost().getSone());
try {
Iterable<Part> parts = parser.parse(parserContext, new StringReader(postPart.getPost().getText()));
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.impl.DefaultSone;
-import net.pterodactylus.sone.database.PostProvider;
-import net.pterodactylus.sone.database.SoneProvider;
+import net.pterodactylus.sone.database.Database;
import net.pterodactylus.util.io.Closer;
import net.pterodactylus.util.logging.Logging;
-import com.google.common.base.Optional;
-
import freenet.keys.FreenetURI;
+import com.google.common.base.Optional;
+
/**
* {@link Parser} implementation that can recognize Freenet URIs.
*
}
- /** The Sone provider. */
- private final SoneProvider soneProvider;
-
- /** The post provider. */
- private final PostProvider postProvider;
+ private final Database database;
/**
* Creates a new freenet link parser.
*
- * @param soneProvider
- * The Sone provider
- * @param postProvider
- * The post provider
+ * @param database
*/
- public SoneTextParser(SoneProvider soneProvider, PostProvider postProvider) {
- this.soneProvider = soneProvider;
- this.postProvider = postProvider;
+ public SoneTextParser(Database database) {
+ this.database = database;
}
//
if (linkType == LinkType.SONE) {
if (line.length() >= (7 + 43)) {
String soneId = line.substring(7, 50);
- Optional<Sone> sone = soneProvider.getSone(soneId);
+ Optional<Sone> sone = database.getSone(soneId);
if (!sone.isPresent()) {
/*
* don’t use create=true above, we don’t want
* the empty shell.
*/
- sone = Optional.<Sone>of(new DefaultSone(soneId, false));
+ sone = Optional.<Sone>of(new DefaultSone(database, soneId, false));
}
parts.add(new SonePart(sone.get()));
line = line.substring(50);
if (linkType == LinkType.POST) {
if (line.length() >= (7 + 36)) {
String postId = line.substring(7, 43);
- Optional<Post> post = postProvider.getPost(postId);
+ Optional<Post> post = database.getPost(postId);
if (post.isPresent()) {
parts.add(new PostPart(post.get()));
} else {
public WebInterface(SonePlugin sonePlugin) {
this.sonePlugin = sonePlugin;
formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
- soneTextParser = new SoneTextParser(getCore(), getCore());
+ soneTextParser = new SoneTextParser(getCore().getDatabase());
templateContextFactory = new TemplateContextFactory();
templateContextFactory.addAccessor(Object.class, new ReflectionAccessor());
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.ImageBuilder;
+import net.pterodactylus.sone.database.memory.MemoryDatabase;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
private final Sone sone = mock(Sone.class);
private final DefaultAlbum album = mock(DefaultAlbum.class);
- private final ImageBuilder imageBuilder = new DefaultImageBuilder(sone, album);
+ private final ImageBuilder imageBuilder = new DefaultImageBuilder(new MemoryDatabase(null), sone, null);
@Test
public void testImageCreationWithAllExplicitParameters() {
import java.io.IOException;
import java.io.StringReader;
import java.util.Arrays;
-import java.util.Collection;
-import com.google.common.base.Optional;
+import net.pterodactylus.sone.database.memory.MemoryDatabase;
import junit.framework.TestCase;
-import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.data.impl.DefaultSone;
-import net.pterodactylus.sone.database.SoneProvider;
/**
* JUnit test case for {@link SoneTextParser}.
*/
@SuppressWarnings("static-method")
public void testPlainText() throws IOException {
- SoneTextParser soneTextParser = new SoneTextParser(null, null);
+ SoneTextParser soneTextParser = new SoneTextParser(new MemoryDatabase(null));
Iterable<Part> parts;
/* check basic operation. */
*/
@SuppressWarnings("static-method")
public void testKSKLinks() throws IOException {
- SoneTextParser soneTextParser = new SoneTextParser(null, null);
+ SoneTextParser soneTextParser = new SoneTextParser(new MemoryDatabase(null));
Iterable<Part> parts;
/* check basic links. */
*/
@SuppressWarnings({ "synthetic-access", "static-method" })
public void testEmptyLinesAndSoneLinks() throws IOException {
- SoneTextParser soneTextParser = new SoneTextParser(new TestSoneProvider(), null);
+ SoneTextParser soneTextParser = new SoneTextParser(new MemoryDatabase(null));
Iterable<Part> parts;
/* check basic links. */
*/
@SuppressWarnings({ "synthetic-access", "static-method" })
public void testEmpyHttpLinks() throws IOException {
- SoneTextParser soneTextParser = new SoneTextParser(new TestSoneProvider(), null);
+ SoneTextParser soneTextParser = new SoneTextParser(new MemoryDatabase(null));
Iterable<Part> parts;
/* check empty http links. */
return text.toString();
}
- /**
- * Mock Sone provider.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
- private static class TestSoneProvider implements SoneProvider {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Optional<Sone> getSone(final String soneId) {
- return Optional.<Sone>of(new DefaultSone(soneId, false) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- return soneId;
- }
- });
- }
-
- /**
- * {@inheritDocs}
- */
- @Override
- public Collection<Sone> getSones() {
- return null;
- }
-
- /**
- * {@inheritDocs}
- */
- @Override
- public Collection<Sone> getLocalSones() {
- return null;
- }
-
- /**
- * {@inheritDocs}
- */
- @Override
- public Collection<Sone> getRemoteSones() {
- return null;
- }
-
- }
-
}