mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-07 17:28:03 +08:00
More tests and changes to allow more tests
This commit is contained in:
parent
0feef90973
commit
110057684e
@ -51,6 +51,10 @@ public class SessionData {
|
||||
public long getSessionEnd() {
|
||||
return sessionEnd;
|
||||
}
|
||||
|
||||
public long getLength() {
|
||||
return sessionEnd-sessionStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -141,6 +141,9 @@ public class UserData {
|
||||
this.isOp = data.isOp();
|
||||
this.isBanned = data.isBanned();
|
||||
DemographicsData dem = data.getDemData();
|
||||
if (dem == null) {
|
||||
dem = new DemographicsData();
|
||||
}
|
||||
this.demData = new DemographicsData(dem.getAge(), dem.getGender(), dem.getGeoLocation());
|
||||
this.mobKills = data.getMobKills();
|
||||
this.playerKills = data.getPlayerKills();
|
||||
|
@ -4,10 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,11 +17,10 @@ public class PlayerActivityGraphCreator {
|
||||
*
|
||||
* @param sessionData
|
||||
* @param scale
|
||||
* @param maxPlayers
|
||||
* @return
|
||||
*/
|
||||
public static String[] generateDataArray(List<SessionData> sessionData, long scale) {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
int maxPlayers = plugin.getHandler().getMaxPlayers();
|
||||
public static String[] generateDataArray(List<SessionData> sessionData, long scale, int maxPlayers) {
|
||||
long now = new Date().toInstant().getEpochSecond() * (long) 1000;
|
||||
long nowMinusScale = now - scale;
|
||||
CopyOnWriteArrayList<Long> sessionStarts = new CopyOnWriteArrayList<>();
|
||||
|
@ -307,14 +307,15 @@ public class Analysis {
|
||||
long scaleDay = 86400 * 1000;
|
||||
long scaleWeek = 604800 * 1000;
|
||||
long scaleMonth = (long) 2592000 * (long) 1000;
|
||||
int maxPlayers = plugin.getHandler().getMaxPlayers();
|
||||
|
||||
data.setNewPlayersDay(AnalysisUtils.getNewPlayers(registered, scaleDay, now));
|
||||
data.setNewPlayersWeek(AnalysisUtils.getNewPlayers(registered, scaleWeek, now));
|
||||
data.setNewPlayersMonth(AnalysisUtils.getNewPlayers(registered, scaleMonth, now));
|
||||
|
||||
String[] dayArray = PlayerActivityGraphCreator.generateDataArray(sData, scaleDay);
|
||||
String[] weekArray = PlayerActivityGraphCreator.generateDataArray(sData, scaleWeek);
|
||||
String[] monthArray = PlayerActivityGraphCreator.generateDataArray(sData, scaleMonth);
|
||||
String[] dayArray = PlayerActivityGraphCreator.generateDataArray(sData, scaleDay, maxPlayers);
|
||||
String[] weekArray = PlayerActivityGraphCreator.generateDataArray(sData, scaleWeek, maxPlayers);
|
||||
String[] monthArray = PlayerActivityGraphCreator.generateDataArray(sData, scaleMonth, maxPlayers);
|
||||
|
||||
data.setPlayersDataArray(new String[]{dayArray[0], dayArray[1], weekArray[0], weekArray[1], monthArray[0], monthArray[1]});
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ public class AnalysisUtils {
|
||||
public static List<Long> transformSessionDataToLengths(Collection<SessionData> data) {
|
||||
List<Long> list = data.stream()
|
||||
.filter(session -> session != null)
|
||||
.filter(session -> session.getSessionEnd() > session.getSessionStart())
|
||||
.map(session -> session.getSessionEnd() - session.getSessionStart())
|
||||
.filter(session -> session.isValid())
|
||||
.map(session -> session.getLength())
|
||||
.collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -28,34 +29,39 @@ public class MiscUtils {
|
||||
* @return String informing about status of plugins version.
|
||||
*/
|
||||
public static String checkVersion() {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
String cVersion;
|
||||
String lineWithVersion;
|
||||
try {
|
||||
URL githubUrl = new URL("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml");
|
||||
lineWithVersion = "";
|
||||
Scanner websiteScanner = new Scanner(githubUrl.openStream());
|
||||
while (websiteScanner.hasNextLine()) {
|
||||
String line = websiteScanner.nextLine();
|
||||
if (line.toLowerCase().contains("version")) {
|
||||
lineWithVersion = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String versionString = lineWithVersion.split(": ")[1];
|
||||
int newestVersionNumber = FormatUtils.parseVersionNumber(versionString);
|
||||
cVersion = plugin.getDescription().getVersion();
|
||||
int currentVersionNumber = FormatUtils.parseVersionNumber(cVersion);
|
||||
if (newestVersionNumber > currentVersionNumber) {
|
||||
plugin.getConfig().set("Settins.Locale", "default");
|
||||
return Phrase.VERSION_NEW_AVAILABLE.parse(versionString);
|
||||
} else {
|
||||
return Phrase.VERSION_LATEST + "";
|
||||
}
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
String cVersion = plugin.getDescription().getVersion();
|
||||
String gitVersion = getGitVersion();
|
||||
return checkVersion(cVersion, gitVersion);
|
||||
} catch (IOException | NumberFormatException e) {
|
||||
plugin.logError(Phrase.VERSION_CHECK_ERROR + "");
|
||||
getPlugin(Plan.class).logError(Phrase.VERSION_CHECK_ERROR + "");
|
||||
}
|
||||
return Phrase.VERSION_FAIL+"";
|
||||
}
|
||||
|
||||
private static String getGitVersion() throws IOException {
|
||||
URL githubUrl = new URL("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml");
|
||||
String lineWithVersion = "";
|
||||
Scanner websiteScanner = new Scanner(githubUrl.openStream());
|
||||
while (websiteScanner.hasNextLine()) {
|
||||
String line = websiteScanner.nextLine();
|
||||
if (line.toLowerCase().contains("version")) {
|
||||
lineWithVersion = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lineWithVersion.split(": ")[1];
|
||||
}
|
||||
|
||||
public static String checkVersion(String currentVersion, String gitVersion) throws NumberFormatException {
|
||||
int newestVersionNumber = FormatUtils.parseVersionNumber(gitVersion);
|
||||
int currentVersionNumber = FormatUtils.parseVersionNumber(currentVersion);
|
||||
if (newestVersionNumber > currentVersionNumber) {
|
||||
return Phrase.VERSION_NEW_AVAILABLE.parse(gitVersion);
|
||||
} else {
|
||||
return Phrase.VERSION_LATEST + "";
|
||||
}
|
||||
return Phrase.VERSION_FAIL + "";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +90,7 @@ public class MiscUtils {
|
||||
Player player = plugin.getServer().getPlayer(UUIDFetcher.getUUIDOf(sender.getName()));
|
||||
playerName = player.getName();
|
||||
} catch (Exception e) {
|
||||
plugin.logError(Phrase.ERROR_CONSOLE_PLAYER.parse(Arrays.toString(args),isConsole+""));
|
||||
plugin.logError(Phrase.ERROR_CONSOLE_PLAYER.parse(Arrays.toString(args), isConsole + ""));
|
||||
}
|
||||
}
|
||||
return playerName;
|
||||
|
@ -179,8 +179,8 @@ public class PlaceholderUtils {
|
||||
Plan plugin = getPlugin(Plan.class);
|
||||
replaceMap.put("%version%", plugin.getDescription().getVersion());
|
||||
replaceMap.put("%planlite%", "");
|
||||
String[] playersDataArray = PlayerActivityGraphCreator.generateDataArray(data.getSessions(), (long) 604800 * 1000);
|
||||
replaceMap.put("%dataweek%", playersDataArray[0].replace(plugin.getHandler().getMaxPlayers() + "]", "2]"));
|
||||
String[] playersDataArray = PlayerActivityGraphCreator.generateDataArray(data.getSessions(), (long) 604800 * 1000, 2);
|
||||
replaceMap.put("%dataweek%", playersDataArray[0]);
|
||||
replaceMap.put("%labelsweek%", playersDataArray[1]);
|
||||
replaceMap.put("%playersgraphcolor%", Settings.HCOLOR_ACT_ONL + "");
|
||||
replaceMap.put("%playersgraphfill%", Settings.HCOLOR_ACT_ONL_FILL + "");
|
||||
|
@ -5,11 +5,11 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan;
|
||||
|
||||
import java.io.File;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -24,6 +24,7 @@ public class PhraseTest {
|
||||
public void testToString() {
|
||||
Phrase instance = Phrase.REPLACE0;
|
||||
String expResult = "REPLACE0";
|
||||
instance.setText(expResult);
|
||||
String result = instance.toString();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
@ -46,7 +47,6 @@ public class PhraseTest {
|
||||
|
||||
@Test
|
||||
public void testColor() {
|
||||
System.out.println("color");
|
||||
Phrase instance = Phrase.COLOR_MAIN;
|
||||
ChatColor expResult = ChatColor.RED;
|
||||
instance.setColor("c");
|
||||
@ -56,7 +56,6 @@ public class PhraseTest {
|
||||
|
||||
@Test
|
||||
public void testSetText() {
|
||||
System.out.println("setText");
|
||||
Phrase instance = Phrase.REPLACE0;
|
||||
String expResult = "Test";
|
||||
instance.setText(expResult);
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.api;
|
||||
|
||||
import main.java.com.djrapitops.plan.api.Gender;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class GenderTest {
|
||||
|
||||
public GenderTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse() {
|
||||
String name = "male";
|
||||
Gender expResult = Gender.MALE;
|
||||
Gender result = Gender.parse(name);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse2() {
|
||||
String name = "female";
|
||||
Gender expResult = Gender.FEMALE;
|
||||
Gender result = Gender.parse(name);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse3() {
|
||||
String name = "other";
|
||||
Gender expResult = Gender.OTHER;
|
||||
Gender result = Gender.parse(name);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse4() {
|
||||
String name = "noeanroe";
|
||||
Gender expResult = Gender.UNKNOWN;
|
||||
Gender result = Gender.parse(name);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data;
|
||||
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.api.Gender;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class DemographicsDataTest {
|
||||
|
||||
public DemographicsDataTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAge() {
|
||||
DemographicsData instance = new DemographicsData();
|
||||
int expResult = -1;
|
||||
int result = instance.getAge();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAge2() {
|
||||
DemographicsData instance = new DemographicsData(10, Gender.OTHER, "None");
|
||||
int expResult = 10;
|
||||
int result = instance.getAge();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGender() {
|
||||
DemographicsData instance = new DemographicsData();
|
||||
Gender expResult = Gender.UNKNOWN;
|
||||
Gender result = instance.getGender();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGender2() {
|
||||
DemographicsData instance = new DemographicsData(10, Gender.OTHER, "None");
|
||||
Gender expResult = Gender.OTHER;
|
||||
Gender result = instance.getGender();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGeoLocation() {
|
||||
DemographicsData instance = new DemographicsData();
|
||||
String expResult = Phrase.DEM_UNKNOWN.parse();
|
||||
String result = instance.getGeoLocation();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
@Test
|
||||
public void testGetGeoLocation2() {
|
||||
DemographicsData instance = new DemographicsData(10, Gender.OTHER, "None");
|
||||
String expResult = "None";
|
||||
String result = instance.getGeoLocation();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAge() {
|
||||
int age = 10;
|
||||
DemographicsData instance = new DemographicsData();
|
||||
instance.setAge(age);
|
||||
int result = instance.getAge();
|
||||
assertEquals(age, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetGender() {
|
||||
Gender gender = Gender.MALE;
|
||||
DemographicsData instance = new DemographicsData();
|
||||
instance.setGender(gender);
|
||||
Gender result = instance.getGender();
|
||||
assertEquals(gender, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetGeoLocation() {
|
||||
String geoLocation = "None";
|
||||
DemographicsData instance = new DemographicsData();
|
||||
instance.setGeoLocation(geoLocation);
|
||||
String result = instance.getGeoLocation();
|
||||
assertEquals(geoLocation, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
DemographicsData instance = new DemographicsData();
|
||||
String expResult = "{age:-1|gender:UNKNOWN|geoLocation:Not Known}";
|
||||
String result = instance.toString();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
}
|
@ -47,5 +47,33 @@ public class SessionDataTest {
|
||||
public void testInvalid() {
|
||||
assertTrue("Supposed to be invalid.", !test.isValid());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInvalid2() {
|
||||
test = new SessionData(3);
|
||||
test.endSession(2);
|
||||
assertTrue("Supposed to be invalid.", !test.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValid2() {
|
||||
test = new SessionData(3);
|
||||
test.endSession(3);
|
||||
assertTrue("Supposed to be valid.", test.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String exp = "s:0 e:-1";
|
||||
String result = test.toString();
|
||||
assertEquals(exp, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLength() {
|
||||
long exp = 5L;
|
||||
test.endSession(5L);
|
||||
long result = test.getLength();
|
||||
assertEquals(exp, result);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class UserDataTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DemographicsData demData = null;
|
||||
DemographicsData demData = new DemographicsData();
|
||||
test = new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, GameMode.CREATIVE, demData, "Testname", true);
|
||||
}
|
||||
|
||||
@ -68,6 +68,13 @@ public class UserDataTest {
|
||||
assertTrue("Added multiples", test.getIps().size() == 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddIpAddressesEmpty() {
|
||||
List<InetAddress> ips = new ArrayList<>();
|
||||
test.addIpAddresses(ips);
|
||||
assertTrue("Added something", test.getIps().isEmpty());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testAddLocation() {
|
||||
@ -110,6 +117,13 @@ public class UserDataTest {
|
||||
assertTrue("Added null", !test.getNicknames().contains(null));
|
||||
assertTrue("Added multiples", test.getNicknames().size() == 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNicknamesEmpty() {
|
||||
List<String> o = new ArrayList<>();
|
||||
test.addNicknames(o);
|
||||
assertTrue("Added something", test.getNicknames().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetGMTime() {
|
||||
@ -178,6 +192,13 @@ public class UserDataTest {
|
||||
assertTrue("Added incorrect one", !test.getSessions().contains(incorrect));
|
||||
assertTrue("Added null", !test.getSessions().contains(incorrect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddSessionsEmpty() {
|
||||
List<SessionData> o = new ArrayList<>();
|
||||
test.addSessions(o);
|
||||
assertTrue("Added something", test.getSessions().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetCurrentSession() {
|
||||
@ -235,4 +256,14 @@ public class UserDataTest {
|
||||
assertTrue("Equals!", !test.equals(o));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyConstructor() {
|
||||
UserData copy = new UserData(test);
|
||||
assertTrue("Not copied properly", test.equals(copy));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUUID() {
|
||||
assertEquals(test.getUuid(), UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.ui.graphs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.ui.graphs.PlayerActivityGraphCreator;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class PlayerActivityGraphCreatorTest {
|
||||
|
||||
public PlayerActivityGraphCreatorTest() {
|
||||
}
|
||||
|
||||
@Ignore("Takes too long") @Test
|
||||
public void testGenerateDataArray() {
|
||||
List<SessionData> sessionData = createRandomSessionDataList();
|
||||
long scale = 2592000L * 1000L;
|
||||
String result = PlayerActivityGraphCreator.generateDataArray(sessionData, scale, 20)[1];
|
||||
assertTrue("0", 0 < result.length());
|
||||
}
|
||||
|
||||
public static List<SessionData> createRandomSessionDataList() {
|
||||
List<SessionData> list = new ArrayList<>();
|
||||
Random r = new Random();
|
||||
long now = new Date().toInstant().getEpochSecond();
|
||||
while (list.size() < 500) {
|
||||
int randomStart = r.nextInt(2592000);
|
||||
long start = now - (long) (randomStart+10);
|
||||
long end = start + (long) r.nextInt(randomStart);
|
||||
list.add(new SessionData((start * (long) 1000), (end * (long) 1000)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class AnalysisUtilsTest {
|
||||
|
||||
public AnalysisUtilsTest() {
|
||||
}
|
||||
|
||||
@Ignore("Mock Settings")@Test
|
||||
public void testIsActive() {
|
||||
long lastPlayed = new Date().getTime();
|
||||
long playTime = 12638934876L;
|
||||
int loginTimes = 4;
|
||||
boolean expResult = false;
|
||||
boolean result = AnalysisUtils.isActive(lastPlayed, playTime, loginTimes);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNewPlayers() {
|
||||
List<Long> registered = new ArrayList<>();
|
||||
registered.add(5L);
|
||||
registered.add(1L);
|
||||
long scale = 8L;
|
||||
long now = 10L;
|
||||
int expResult = 1;
|
||||
int result = AnalysisUtils.getNewPlayers(registered, scale, now);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNewPlayersEmpty() {
|
||||
List<Long> registered = new ArrayList<>();
|
||||
long scale = 1L;
|
||||
long now = 2L;
|
||||
int expResult = 0;
|
||||
int result = AnalysisUtils.getNewPlayers(registered, scale, now);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransformSessionDataToLengths() {
|
||||
Collection<SessionData> data = new ArrayList<>();
|
||||
data.add(new SessionData(0, 5L));
|
||||
data.add(new SessionData(0, 20L));
|
||||
data.add(new SessionData(0));
|
||||
List<Long> expResult = new ArrayList<>();
|
||||
expResult.add(5L);
|
||||
expResult.add(20L);
|
||||
List<Long> result = AnalysisUtils.transformSessionDataToLengths(data);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAverage() {
|
||||
Collection<Long> o = new ArrayList<>();
|
||||
o.add(0L);
|
||||
o.add(1L);
|
||||
o.add(2L);
|
||||
o.add(3L);
|
||||
o.add(4L);
|
||||
long expResult = 2L;
|
||||
long result = AnalysisUtils.average(o);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAverageEmpty() {
|
||||
Collection<Long> list = new ArrayList<>();
|
||||
long expResult = 0L;
|
||||
long result = AnalysisUtils.average(list);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
}
|
@ -23,11 +23,33 @@ public class MiscUtilsTest {
|
||||
public MiscUtilsTest() {
|
||||
}
|
||||
|
||||
@Ignore @Test
|
||||
@Test
|
||||
public void testCheckVersion() {
|
||||
System.out.println("checkVersion");
|
||||
String result = MiscUtils.checkVersion();
|
||||
assertTrue("Failed", !result.equals(Phrase.VERSION_CHECK_ERROR + ""));
|
||||
String versionG = "2.10.9";
|
||||
String result = MiscUtils.checkVersion("2.0.0", versionG);
|
||||
String exp = Phrase.VERSION_NEW_AVAILABLE.parse(versionG);
|
||||
assertEquals(exp, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckVersion2() {
|
||||
String result = MiscUtils.checkVersion("3.0.0", "2.10.9");
|
||||
String exp = Phrase.VERSION_LATEST+"";
|
||||
assertEquals(exp, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckVersion3() {
|
||||
String result = MiscUtils.checkVersion("2.11.0", "2.10.9");
|
||||
String exp = Phrase.VERSION_LATEST+"";
|
||||
assertEquals(exp, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckVersion4() {
|
||||
String result = MiscUtils.checkVersion("2.11.0", "2.11.0");
|
||||
String exp = Phrase.VERSION_LATEST+"";
|
||||
assertEquals(exp, result);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
Loading…
Reference in New Issue
Block a user