diff --git a/pom.xml b/pom.xml
index ed8c44e..1aca807 100644
--- a/pom.xml
+++ b/pom.xml
@@ -115,6 +115,12 @@
4.12
test
+
+ org.mockito
+ mockito-core
+ 2.6.5
+ test
+
com.1stleg
jnativehook
diff --git a/src/test/java/musicplayer/db/HibernateDatabaseTest.java b/src/test/java/musicplayer/db/HibernateDatabaseTest.java
index bcc93a4..045da02 100644
--- a/src/test/java/musicplayer/db/HibernateDatabaseTest.java
+++ b/src/test/java/musicplayer/db/HibernateDatabaseTest.java
@@ -7,6 +7,11 @@ import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.id3.ID3v23Tag;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.mockito.Mockito.*;
import java.io.File;
import java.nio.file.Path;
@@ -17,10 +22,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+@RunWith(MockitoJUnitRunner.class)
public class HibernateDatabaseTest {
private IDatabase database;
+ @Mock
+ ILibrary library;
+
@Before
public void setUp(){
database = new HibernateDatabase(true);
@@ -222,41 +231,8 @@ public class HibernateDatabaseTest {
Path dir = new File(HibernateDatabaseTest.class.getResource("/sample.mp3").getFile()).getParentFile().toPath();
List dirList = new ArrayList<>();
dirList.add(dir);
- FakeLibrary library = new FakeLibrary(database);
database.processSongsWithCallback(library, dirList);
assertEquals(1, database.listAllT(Song.class).get().size());
- assertTrue(library.success);
- assertFalse(library.failed);
- }
-
- private class FakeLibrary extends ILibrary{
-
- public boolean success = false;
- public boolean failed = false;
-
- public FakeLibrary(IDatabase database) {
- super(database);
- }
-
- @Override
- public void showSongs() {}
-
- @Override
- public > void showGroupedSongs(Class grouping) {}
-
- @Override
- public void updateLibrary() {}
-
- @Override
- public void refreshLibrary() {}
-
- @Override
- public void libraryUpdateFailed(String message) { failed = true;}
-
- @Override
- public void libraryUpdated() { success = true;}
-
- @Override
- public void currentlyUpdating(String name) {}
+ verify(library).libraryUpdated();
}
}
\ No newline at end of file