this.database = database;
}
+ @VisibleForTesting
+ protected Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, SoneDownloader soneDownloader, ImageInserter imageInserter, UpdateChecker updateChecker, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database) {
+ super("Sone Core");
+ this.configuration = configuration;
+ this.freenetInterface = freenetInterface;
+ this.identityManager = identityManager;
+ this.soneDownloader = soneDownloader;
+ this.imageInserter = imageInserter;
+ this.updateChecker = updateChecker;
+ this.webOfTrustUpdater = webOfTrustUpdater;
+ this.eventBus = eventBus;
+ this.database = database;
+ }
+
//
// ACCESSORS
//
* The ID of the album
* @return The album with the given ID
*/
- public Album getAlbum(String albumId) {
+ public Album getOrCreateAlbum(String albumId) {
return getAlbum(albumId, true);
}
logger.log(Level.WARNING, "Invalid album found, aborting load!");
return;
}
- Album album = getAlbum(albumId).setSone(sone).modify().setTitle(albumTitle).setDescription(albumDescription).setAlbumImage(albumImageId).update();
+ Album album = getOrCreateAlbum(albumId).setSone(sone).modify().setTitle(albumTitle).setDescription(albumDescription).setAlbumImage(albumImageId).update();
if (albumParentId != null) {
Album parentAlbum = getAlbum(albumParentId, false);
if (parentAlbum == null) {
public void setupAlbums() {
albums.put("album-id-1", new AlbumImpl("album-id-1"));
albums.put("album-id-2", new AlbumImpl("album-id-2"));
- when(core.getAlbum(anyString())).thenAnswer(new Answer<Album>() {
+ when(core.getOrCreateAlbum(anyString())).thenAnswer(new Answer<Album>() {
@Override
public Album answer(InvocationOnMock invocation) throws Throwable {
return albums.get(invocation.getArguments()[0]);