added testing
This commit is contained in:
parent
d720645735
commit
59bb4fdb6f
@ -40,9 +40,13 @@ dependencies {
|
|||||||
implementation 'com.mashape.unirest:unirest-java:1.4.9'
|
implementation 'com.mashape.unirest:unirest-java:1.4.9'
|
||||||
implementation 'org.json:json:20180813'
|
implementation 'org.json:json:20180813'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation('org.junit.jupiter:junit-jupiter-api:5.4.2')
|
||||||
|
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.4.2')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package sarsoo.fmframework.cache;
|
package sarsoo.fmframework.cache;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import sarsoo.fmframework.cache.puller.AlbumPuller;
|
import sarsoo.fmframework.cache.puller.AlbumPuller;
|
||||||
import sarsoo.fmframework.cache.puller.ArtistPuller;
|
import sarsoo.fmframework.cache.puller.ArtistPuller;
|
||||||
@ -35,7 +33,7 @@ public class AlbumCacheTest {
|
|||||||
artistCache.dumpToLog(new Log());
|
artistCache.dumpToLog(new Log());
|
||||||
cache.dumpToLog(new Log());
|
cache.dumpToLog(new Log());
|
||||||
|
|
||||||
assertTrue(true);
|
// assertThat();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package sarsoo.fmframework.cache;
|
package sarsoo.fmframework.cache;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import sarsoo.fmframework.cache.puller.AlbumPuller;
|
import sarsoo.fmframework.cache.puller.AlbumPuller;
|
||||||
import sarsoo.fmframework.fm.FmUserNetwork;
|
import sarsoo.fmframework.fm.FmUserNetwork;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package sarsoo.fmframework.config;
|
package sarsoo.fmframework.config;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ConfigPersisterTest {
|
public class ConfigPersisterTest {
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package sarsoo.fmframework.fm;
|
package sarsoo.fmframework.fm;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import sarsoo.fmframework.music.Scrobble;
|
import sarsoo.fmframework.music.Scrobble;
|
||||||
import sarsoo.fmframework.music.Track.TrackBuilder;
|
import sarsoo.fmframework.music.Track.TrackBuilder;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package sarsoo.fmframework.fm;
|
package sarsoo.fmframework.fm;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import sarsoo.fmframework.error.ApiCallException;
|
import sarsoo.fmframework.error.ApiCallException;
|
||||||
import sarsoo.fmframework.music.Album;
|
import sarsoo.fmframework.music.Album;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package sarsoo.fmframework.fm;
|
package sarsoo.fmframework.fm;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import sarsoo.fmframework.music.Scrobble;
|
import sarsoo.fmframework.music.Scrobble;
|
||||||
import sarsoo.fmframework.music.Track;
|
import sarsoo.fmframework.music.Track;
|
||||||
import sarsoo.fmframework.music.Track.TrackBuilder;
|
import sarsoo.fmframework.music.Track.TrackBuilder;
|
||||||
@ -10,7 +8,9 @@ import sarsoo.fmframework.music.Artist.ArtistBuilder;
|
|||||||
import sarsoo.fmframework.net.Key;
|
import sarsoo.fmframework.net.Key;
|
||||||
import sarsoo.fmframework.util.FMObjList;
|
import sarsoo.fmframework.util.FMObjList;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class FmUserNetworkTest {
|
|||||||
try {
|
try {
|
||||||
assertNotNull(new FmUserNetwork(Key.getKey(), "sarsoo").getLastTrack());
|
assertNotNull(new FmUserNetwork(Key.getKey(), "sarsoo").getLastTrack());
|
||||||
} catch (ApiCallException e) {
|
} catch (ApiCallException e) {
|
||||||
e.printStackTrace();
|
fail("APICallException" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,18 +34,16 @@ public class FmUserNetworkTest {
|
|||||||
public void testGetRecentTracks() {
|
public void testGetRecentTracks() {
|
||||||
FmUserNetwork net = new FmUserNetwork(Key.getKey(), "sarsoo");
|
FmUserNetwork net = new FmUserNetwork(Key.getKey(), "sarsoo");
|
||||||
|
|
||||||
int limit = 50;
|
int limit = 30;
|
||||||
|
|
||||||
ArrayList<Scrobble> scrobbles;
|
ArrayList<Scrobble> scrobbles;
|
||||||
try {
|
try {
|
||||||
scrobbles = net.getRecentScrobbles(limit);
|
scrobbles = net.getRecentScrobbles(limit);
|
||||||
|
|
||||||
// scrobbles.stream().forEach(System.out::println);
|
|
||||||
System.out.println(scrobbles.size());
|
|
||||||
assertEquals(limit, scrobbles.size());
|
assertEquals(limit, scrobbles.size());
|
||||||
|
|
||||||
} catch (ApiCallException e) {
|
} catch (ApiCallException e) {
|
||||||
e.printStackTrace();
|
fail("APICallException" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,17 +51,16 @@ public class FmUserNetworkTest {
|
|||||||
public void testGetTopAlbums() {
|
public void testGetTopAlbums() {
|
||||||
FmUserNetwork net = new FmUserNetwork(Key.getKey(), "sarsoo");
|
FmUserNetwork net = new FmUserNetwork(Key.getKey(), "sarsoo");
|
||||||
|
|
||||||
int limit = 50;
|
int limit = 30;
|
||||||
|
|
||||||
FMObjList list;
|
FMObjList list;
|
||||||
try {
|
try {
|
||||||
list = net.getTopAlbums("7day", limit);
|
list = net.getTopAlbums("7day", limit);
|
||||||
|
|
||||||
// list.stream().forEach(System.out::println);
|
|
||||||
assertEquals(limit, list.size());
|
assertEquals(limit, list.size());
|
||||||
|
|
||||||
} catch (ApiCallException e) {
|
} catch (ApiCallException e) {
|
||||||
e.printStackTrace();
|
fail("APICallException" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package sarsoo.fmframework.log;
|
package sarsoo.fmframework.log;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import sarsoo.fmframework.log.entry.ErrorEntry;
|
import sarsoo.fmframework.log.entry.ErrorEntry;
|
||||||
import sarsoo.fmframework.log.entry.InfoEntry;
|
import sarsoo.fmframework.log.entry.InfoEntry;
|
||||||
@ -13,15 +13,7 @@ public class LogTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testDump() {
|
public void testDump() {
|
||||||
|
|
||||||
Log log = Logger.getLog();
|
Log log = new Log();
|
||||||
|
|
||||||
log.log(new LogEntry("log test"));
|
|
||||||
log.logInfo(new InfoEntry("log test"));
|
|
||||||
log.logError(new ErrorEntry("log test"));
|
|
||||||
|
|
||||||
// log.dumpLog();
|
|
||||||
// log.dumpInfoLog();
|
|
||||||
// log.dumpErrorLog();
|
|
||||||
|
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,178 @@
|
|||||||
package sarsoo.fmframework.util;
|
package sarsoo.fmframework.util;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import sarsoo.fmframework.music.Album;
|
||||||
|
import sarsoo.fmframework.music.Album.AlbumBuilder;
|
||||||
|
import sarsoo.fmframework.music.Artist;
|
||||||
|
import sarsoo.fmframework.music.Artist.ArtistBuilder;
|
||||||
|
import sarsoo.fmframework.music.Track;
|
||||||
|
import sarsoo.fmframework.music.Track.TrackBuilder;
|
||||||
|
|
||||||
|
@DisplayName("FMObjList tests")
|
||||||
public class FMObjListTest {
|
public class FMObjListTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSeparateAlbumAddition() {
|
@DisplayName("empty instantiation not null")
|
||||||
|
public void testNotNull() {
|
||||||
FMObjList list = new FMObjList();
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
// Album album = new Album();
|
assertNotNull(list);
|
||||||
|
}
|
||||||
|
|
||||||
// fail("Not yet implemented");
|
@Test
|
||||||
|
@DisplayName("test get name")
|
||||||
|
public void testGetName() {
|
||||||
|
String testName = "test name";
|
||||||
|
|
||||||
|
FMObjList list = new FMObjList(testName);
|
||||||
|
|
||||||
|
assertEquals(testName, list.getGroupName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test artist total count")
|
||||||
|
public void testArtistsGetScrobbleCount() {
|
||||||
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
|
int scrobbleCount = 20;
|
||||||
|
int scrobbleCount2 = 30;
|
||||||
|
|
||||||
|
Artist artist = new ArtistBuilder("artist name").setUserPlayCount(scrobbleCount).build();
|
||||||
|
Artist artist2 = new ArtistBuilder("artist name2").setUserPlayCount(scrobbleCount2).build();
|
||||||
|
|
||||||
|
list.add(artist);
|
||||||
|
list.add(artist2);
|
||||||
|
|
||||||
|
assertEquals(scrobbleCount + scrobbleCount2, list.getTotalUserScrobbles());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test album count ignored with present artist")
|
||||||
|
public void testArtistsAlbumsGetScrobbleCount() {
|
||||||
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
|
int artistScrobbleCount = 20;
|
||||||
|
int artistScrobbleCount2 = 30;
|
||||||
|
|
||||||
|
Artist artist = new ArtistBuilder("artist name").setUserPlayCount(artistScrobbleCount).build();
|
||||||
|
Artist artist2 = new ArtistBuilder("artist name2").setUserPlayCount(artistScrobbleCount2).build();
|
||||||
|
|
||||||
|
Album album = new AlbumBuilder("album name", artist).setUserPlayCount(10).build();
|
||||||
|
|
||||||
|
list.add(artist);
|
||||||
|
list.add(artist2);
|
||||||
|
list.add(album);
|
||||||
|
|
||||||
|
assertEquals(artistScrobbleCount + artistScrobbleCount2, list.getTotalUserScrobbles());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test multiple album count ignored with present artist")
|
||||||
|
public void testArtistsMultipleAlbumsGetScrobbleCount() {
|
||||||
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
|
int artistScrobbleCount = 20;
|
||||||
|
int artistScrobbleCount2 = 30;
|
||||||
|
|
||||||
|
Artist artist = new ArtistBuilder("artist name").setUserPlayCount(artistScrobbleCount).build();
|
||||||
|
Artist artist2 = new ArtistBuilder("artist name2").setUserPlayCount(artistScrobbleCount2).build();
|
||||||
|
|
||||||
|
Album album = new AlbumBuilder("album name", artist).setUserPlayCount(10).build();
|
||||||
|
Album album2 = new AlbumBuilder("album name2", artist2).setUserPlayCount(5).build();
|
||||||
|
|
||||||
|
list.add(artist);
|
||||||
|
list.add(artist2);
|
||||||
|
list.add(album);
|
||||||
|
list.add(album2);
|
||||||
|
|
||||||
|
assertEquals(artistScrobbleCount + artistScrobbleCount2, list.getTotalUserScrobbles());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test track count ignored with present artist")
|
||||||
|
public void testArtistsTrackGetScrobbleCount() {
|
||||||
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
|
int artistScrobbleCount = 20;
|
||||||
|
int artistScrobbleCount2 = 30;
|
||||||
|
|
||||||
|
Artist artist = new ArtistBuilder("artist name").setUserPlayCount(artistScrobbleCount).build();
|
||||||
|
Artist artist2 = new ArtistBuilder("artist name2").setUserPlayCount(artistScrobbleCount2).build();
|
||||||
|
|
||||||
|
Track track = new TrackBuilder("track name", artist2).setUserPlayCount(5).build();
|
||||||
|
|
||||||
|
list.add(artist);
|
||||||
|
list.add(artist2);
|
||||||
|
list.add(track);
|
||||||
|
|
||||||
|
assertEquals(artistScrobbleCount + artistScrobbleCount2, list.getTotalUserScrobbles());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test track/album count ignored with present artist")
|
||||||
|
public void testArtistAlbumTrackGetScrobbleCount() {
|
||||||
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
|
int artistScrobbleCount = 20;
|
||||||
|
int artistScrobbleCount2 = 30;
|
||||||
|
|
||||||
|
Artist artist = new ArtistBuilder("artist name").setUserPlayCount(artistScrobbleCount).build();
|
||||||
|
Artist artist2 = new ArtistBuilder("artist name2").setUserPlayCount(artistScrobbleCount2).build();
|
||||||
|
|
||||||
|
Album album = new AlbumBuilder("album name", artist).setUserPlayCount(10).build();
|
||||||
|
|
||||||
|
Track track = new TrackBuilder("track name", artist).setAlbum(album).setUserPlayCount(5).build();
|
||||||
|
|
||||||
|
list.add(artist);
|
||||||
|
list.add(artist2);
|
||||||
|
list.add(album);
|
||||||
|
list.add(track);
|
||||||
|
|
||||||
|
assertEquals(artistScrobbleCount + artistScrobbleCount2, list.getTotalUserScrobbles());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test track count ignored with present album")
|
||||||
|
public void testAlbumTrackGetScrobbleCount() {
|
||||||
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
|
int artistScrobbleCount = 20;
|
||||||
|
|
||||||
|
Artist artist = new ArtistBuilder("artist name").setUserPlayCount(artistScrobbleCount).build();
|
||||||
|
|
||||||
|
Album album = new AlbumBuilder("album name", artist).setUserPlayCount(10).build();
|
||||||
|
|
||||||
|
Track track = new TrackBuilder("track name", artist).setAlbum(album).setUserPlayCount(5).build();
|
||||||
|
|
||||||
|
list.add(album);
|
||||||
|
list.add(track);
|
||||||
|
|
||||||
|
assertEquals(10, list.getTotalUserScrobbles());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test multiple tracks count ignored with present album")
|
||||||
|
public void testAlbumTracksGetScrobbleCount() {
|
||||||
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
|
int artistScrobbleCount = 20;
|
||||||
|
|
||||||
|
Artist artist = new ArtistBuilder("artist name").setUserPlayCount(artistScrobbleCount).build();
|
||||||
|
|
||||||
|
Album album = new AlbumBuilder("album name", artist).setUserPlayCount(20).build();
|
||||||
|
|
||||||
|
Track track = new TrackBuilder("track name", artist).setAlbum(album).setUserPlayCount(5).build();
|
||||||
|
Track track2 = new TrackBuilder("track name2", artist).setAlbum(album).setUserPlayCount(10).build();
|
||||||
|
|
||||||
|
list.add(album);
|
||||||
|
list.add(track);
|
||||||
|
list.add(track2);
|
||||||
|
|
||||||
|
assertEquals(20, list.getTotalUserScrobbles());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user