Use more specific query to get logged in players without email
- Reduces the amount of data returned from the DB and the work required to build objects
This commit is contained in:
parent
2f7ebc0ecb
commit
04ca36fe53
@ -2,7 +2,6 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
@ -65,16 +64,13 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
|||||||
* @param sender the sender initiating the password change
|
* @param sender the sender initiating the password change
|
||||||
*/
|
*/
|
||||||
private void changePassword(String nameLowercase, String password, CommandSender sender) {
|
private void changePassword(String nameLowercase, String password, CommandSender sender) {
|
||||||
PlayerAuth auth = getAuth(nameLowercase);
|
if (!isNameRegistered(nameLowercase)) {
|
||||||
if (auth == null) {
|
|
||||||
commonService.send(sender, MessageKey.UNKNOWN_USER);
|
commonService.send(sender, MessageKey.UNKNOWN_USER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedPassword hashedPassword = passwordSecurity.computeHash(password, nameLowercase);
|
HashedPassword hashedPassword = passwordSecurity.computeHash(password, nameLowercase);
|
||||||
auth.setPassword(hashedPassword);
|
if (dataSource.updatePassword(nameLowercase, hashedPassword)) {
|
||||||
|
|
||||||
if (dataSource.updatePassword(auth)) {
|
|
||||||
commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||||
ConsoleLogger.info(sender.getName() + " changed password of " + nameLowercase);
|
ConsoleLogger.info(sender.getName() + " changed password of " + nameLowercase);
|
||||||
} else {
|
} else {
|
||||||
@ -82,12 +78,7 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerAuth getAuth(String nameLowercase) {
|
private boolean isNameRegistered(String nameLowercase) {
|
||||||
if (playerCache.isAuthenticated(nameLowercase)) {
|
return playerCache.isAuthenticated(nameLowercase) || dataSource.isAuthAvailable(nameLowercase);
|
||||||
return playerCache.getAuth(nameLowercase);
|
|
||||||
} else if (dataSource.isAuthAvailable(nameLowercase)) {
|
|
||||||
return dataSource.getAuth(nameLowercase);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,6 @@ class DataStatistics implements DebugSection {
|
|||||||
|
|
||||||
private void outputDatabaseStats(CommandSender sender) {
|
private void outputDatabaseStats(CommandSender sender) {
|
||||||
sender.sendMessage("Total players in DB: " + dataSource.getAccountsRegistered());
|
sender.sendMessage("Total players in DB: " + dataSource.getAccountsRegistered());
|
||||||
sender.sendMessage("Total marked as logged in in DB: " + dataSource.getLoggedPlayers().size());
|
|
||||||
if (dataSource instanceof CacheDataSource) {
|
if (dataSource instanceof CacheDataSource) {
|
||||||
CacheDataSource cacheDataSource = (CacheDataSource) this.dataSource;
|
CacheDataSource cacheDataSource = (CacheDataSource) this.dataSource;
|
||||||
sender.sendMessage("Cached PlayerAuth objects: " + cacheDataSource.getCachedAuths().size());
|
sender.sendMessage("Cached PlayerAuth objects: " + cacheDataSource.getCachedAuths().size());
|
||||||
|
|||||||
@ -11,14 +11,15 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.data.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
import fr.xephi.authme.util.Utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CacheDataSource implements DataSource {
|
public class CacheDataSource implements DataSource {
|
||||||
|
|
||||||
@ -240,7 +241,10 @@ public class CacheDataSource implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlayerAuth> getLoggedPlayers() {
|
public List<String> getLoggedPlayersWithEmptyMail() {
|
||||||
return new ArrayList<>(playerCache.getCache().values());
|
return playerCache.getCache().values().stream()
|
||||||
|
.filter(auth -> Utils.isEmailEmpty(auth.getEmail()))
|
||||||
|
.map(PlayerAuth::getRealName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -167,11 +167,11 @@ public interface DataSource extends Reloadable {
|
|||||||
void purgeLogged();
|
void purgeLogged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all players which are logged in.
|
* Return all players which are logged in and whose email is not set.
|
||||||
*
|
*
|
||||||
* @return All logged in players
|
* @return logged in players with no email
|
||||||
*/
|
*/
|
||||||
List<PlayerAuth> getLoggedPlayers();
|
List<String> getLoggedPlayersWithEmptyMail();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of registered accounts.
|
* Return the number of registered accounts.
|
||||||
|
|||||||
@ -423,7 +423,7 @@ public class FlatFile implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlayerAuth> getLoggedPlayers() {
|
public List<String> getLoggedPlayersWithEmptyMail() {
|
||||||
throw new UnsupportedOperationException("Flat file no longer supported");
|
throw new UnsupportedOperationException("Flat file no longer supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -927,33 +927,20 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlayerAuth> getLoggedPlayers() {
|
public List<String> getLoggedPlayersWithEmptyMail() {
|
||||||
List<PlayerAuth> auths = new ArrayList<>();
|
List<String> players = new ArrayList<>();
|
||||||
String sql = "SELECT * FROM " + tableName + " WHERE " + col.IS_LOGGED + "=1;";
|
String sql = "SELECT " + col.REAL_NAME + " FROM " + tableName + " WHERE " + col.IS_LOGGED + " = 1"
|
||||||
|
+ " AND (" + col.EMAIL + " = 'your@email.com' OR " + col.EMAIL + " IS NULL);";
|
||||||
try (Connection con = getConnection();
|
try (Connection con = getConnection();
|
||||||
Statement st = con.createStatement();
|
Statement st = con.createStatement();
|
||||||
ResultSet rs = st.executeQuery(sql)) {
|
ResultSet rs = st.executeQuery(sql)) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
PlayerAuth pAuth = buildAuthFromResultSet(rs);
|
players.add(rs.getString(1));
|
||||||
if (hashAlgorithm == HashAlgorithm.XFBCRYPT) {
|
|
||||||
try (PreparedStatement pst = con.prepareStatement("SELECT data FROM xf_user_authenticate WHERE " + col.ID + "=?;")) {
|
|
||||||
int id = rs.getInt(col.ID);
|
|
||||||
pst.setInt(1, id);
|
|
||||||
ResultSet rs2 = pst.executeQuery();
|
|
||||||
if (rs2.next()) {
|
|
||||||
Blob blob = rs2.getBlob("data");
|
|
||||||
byte[] bytes = blob.getBytes(1, (int) blob.length());
|
|
||||||
pAuth.setPassword(new HashedPassword(XfBCrypt.getHashFromBlob(bytes)));
|
|
||||||
}
|
|
||||||
rs2.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auths.add(pAuth);
|
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
return auths;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
|
private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
|
||||||
|
|||||||
@ -591,18 +591,18 @@ public class SQLite implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlayerAuth> getLoggedPlayers() {
|
public List<String> getLoggedPlayersWithEmptyMail() {
|
||||||
List<PlayerAuth> auths = new ArrayList<>();
|
List<String> players = new ArrayList<>();
|
||||||
String sql = "SELECT * FROM " + tableName + " WHERE " + col.IS_LOGGED + "=1;";
|
String sql = "SELECT " + col.REAL_NAME + " FROM " + tableName + " WHERE " + col.IS_LOGGED + " = 1"
|
||||||
try (PreparedStatement pst = con.prepareStatement(sql); ResultSet rs = pst.executeQuery()) {
|
+ " AND (" + col.EMAIL + " = 'your@email.com' OR " + col.EMAIL + " IS NULL);";
|
||||||
|
try (Statement st = con.createStatement(); ResultSet rs = st.executeQuery(sql)) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
PlayerAuth auth = buildAuthFromResultSet(rs);
|
players.add(rs.getString(1));
|
||||||
auths.add(auth);
|
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
return auths;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
|
private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package fr.xephi.authme.initialization;
|
|||||||
import ch.jalu.injector.exceptions.InjectorReflectionException;
|
import ch.jalu.injector.exceptions.InjectorReflectionException;
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.message.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.message.Messages;
|
import fr.xephi.authme.message.Messages;
|
||||||
@ -18,7 +17,6 @@ import fr.xephi.authme.settings.properties.DatabaseSettings;
|
|||||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.Utils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.bstats.Metrics;
|
import org.bstats.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -110,16 +108,13 @@ public class OnStartupTasks {
|
|||||||
bukkitService.runTaskTimerAsynchronously(new Runnable() {
|
bukkitService.runTaskTimerAsynchronously(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (PlayerAuth auth : dataSource.getLoggedPlayers()) {
|
for (String playerWithoutMail : dataSource.getLoggedPlayersWithEmptyMail()) {
|
||||||
String email = auth.getEmail();
|
Player player = bukkitService.getPlayerExact(playerWithoutMail);
|
||||||
if (Utils.isEmailEmpty(email)) {
|
|
||||||
Player player = bukkitService.getPlayerExact(auth.getRealName());
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
messages.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
messages.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, 1, TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL));
|
}, 1, TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,14 +101,11 @@ public class ChangePasswordAdminCommandTest {
|
|||||||
CommandSender sender = mock(CommandSender.class);
|
CommandSender sender = mock(CommandSender.class);
|
||||||
String player = "my_user12";
|
String player = "my_user12";
|
||||||
String password = "passPass";
|
String password = "passPass";
|
||||||
PlayerAuth auth = mock(PlayerAuth.class);
|
|
||||||
|
|
||||||
given(playerCache.isAuthenticated(player)).willReturn(true);
|
given(playerCache.isAuthenticated(player)).willReturn(true);
|
||||||
given(playerCache.getAuth(player)).willReturn(auth);
|
|
||||||
|
|
||||||
HashedPassword hashedPassword = mock(HashedPassword.class);
|
HashedPassword hashedPassword = mock(HashedPassword.class);
|
||||||
given(passwordSecurity.computeHash(password, player)).willReturn(hashedPassword);
|
given(passwordSecurity.computeHash(password, player)).willReturn(hashedPassword);
|
||||||
given(dataSource.updatePassword(auth)).willReturn(true);
|
given(dataSource.updatePassword(player, hashedPassword)).willReturn(true);
|
||||||
given(validationService.validatePassword(password, player)).willReturn(new ValidationResult());
|
given(validationService.validatePassword(password, player)).willReturn(new ValidationResult());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -119,8 +116,7 @@ public class ChangePasswordAdminCommandTest {
|
|||||||
verify(validationService).validatePassword(password, player);
|
verify(validationService).validatePassword(password, player);
|
||||||
verify(service).send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
verify(service).send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||||
verify(passwordSecurity).computeHash(password, player);
|
verify(passwordSecurity).computeHash(password, player);
|
||||||
verify(auth).setPassword(hashedPassword);
|
verify(dataSource).updatePassword(player, hashedPassword);
|
||||||
verify(dataSource).updatePassword(auth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -129,15 +125,13 @@ public class ChangePasswordAdminCommandTest {
|
|||||||
CommandSender sender = mock(CommandSender.class);
|
CommandSender sender = mock(CommandSender.class);
|
||||||
String player = "my_user12";
|
String player = "my_user12";
|
||||||
String password = "passPass";
|
String password = "passPass";
|
||||||
PlayerAuth auth = mock(PlayerAuth.class);
|
|
||||||
given(playerCache.isAuthenticated(player)).willReturn(false);
|
given(playerCache.isAuthenticated(player)).willReturn(false);
|
||||||
given(dataSource.isAuthAvailable(player)).willReturn(true);
|
given(dataSource.isAuthAvailable(player)).willReturn(true);
|
||||||
given(dataSource.getAuth(player)).willReturn(auth);
|
|
||||||
given(dataSource.updatePassword(auth)).willReturn(true);
|
|
||||||
given(validationService.validatePassword(password, player)).willReturn(new ValidationResult());
|
given(validationService.validatePassword(password, player)).willReturn(new ValidationResult());
|
||||||
|
|
||||||
HashedPassword hashedPassword = mock(HashedPassword.class);
|
HashedPassword hashedPassword = mock(HashedPassword.class);
|
||||||
given(passwordSecurity.computeHash(password, player)).willReturn(hashedPassword);
|
given(passwordSecurity.computeHash(password, player)).willReturn(hashedPassword);
|
||||||
|
given(dataSource.updatePassword(player, hashedPassword)).willReturn(true);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
command.executeCommand(sender, Arrays.asList(player, password));
|
command.executeCommand(sender, Arrays.asList(player, password));
|
||||||
@ -147,8 +141,7 @@ public class ChangePasswordAdminCommandTest {
|
|||||||
verify(validationService).validatePassword(password, player);
|
verify(validationService).validatePassword(password, player);
|
||||||
verify(service).send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
verify(service).send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||||
verify(passwordSecurity).computeHash(password, player);
|
verify(passwordSecurity).computeHash(password, player);
|
||||||
verify(auth).setPassword(hashedPassword);
|
verify(dataSource).updatePassword(player, hashedPassword);
|
||||||
verify(dataSource).updatePassword(auth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -157,14 +150,12 @@ public class ChangePasswordAdminCommandTest {
|
|||||||
CommandSender sender = mock(CommandSender.class);
|
CommandSender sender = mock(CommandSender.class);
|
||||||
String player = "my_user12";
|
String player = "my_user12";
|
||||||
String password = "passPass";
|
String password = "passPass";
|
||||||
PlayerAuth auth = mock(PlayerAuth.class);
|
|
||||||
given(playerCache.isAuthenticated(player)).willReturn(true);
|
given(playerCache.isAuthenticated(player)).willReturn(true);
|
||||||
given(playerCache.getAuth(player)).willReturn(auth);
|
|
||||||
given(validationService.validatePassword(password, player)).willReturn(new ValidationResult());
|
given(validationService.validatePassword(password, player)).willReturn(new ValidationResult());
|
||||||
|
|
||||||
HashedPassword hashedPassword = mock(HashedPassword.class);
|
HashedPassword hashedPassword = mock(HashedPassword.class);
|
||||||
given(passwordSecurity.computeHash(password, player)).willReturn(hashedPassword);
|
given(passwordSecurity.computeHash(password, player)).willReturn(hashedPassword);
|
||||||
given(dataSource.updatePassword(auth)).willReturn(false);
|
given(dataSource.updatePassword(player, hashedPassword)).willReturn(false);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
command.executeCommand(sender, Arrays.asList(player, password));
|
command.executeCommand(sender, Arrays.asList(player, password));
|
||||||
@ -174,8 +165,7 @@ public class ChangePasswordAdminCommandTest {
|
|||||||
verify(validationService).validatePassword(password, player);
|
verify(validationService).validatePassword(password, player);
|
||||||
verify(service).send(sender, MessageKey.ERROR);
|
verify(service).send(sender, MessageKey.ERROR);
|
||||||
verify(passwordSecurity).computeHash(password, player);
|
verify(passwordSecurity).computeHash(password, player);
|
||||||
verify(auth).setPassword(hashedPassword);
|
verify(dataSource).updatePassword(player, hashedPassword);
|
||||||
verify(dataSource).updatePassword(auth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -348,7 +348,8 @@ public abstract class AbstractDataSourceIntegrationTest {
|
|||||||
public void shouldPerformOperationsOnIsLoggedColumnSuccessfully() {
|
public void shouldPerformOperationsOnIsLoggedColumnSuccessfully() {
|
||||||
DataSource dataSource = getDataSource();
|
DataSource dataSource = getDataSource();
|
||||||
// on startup no one should be marked as logged
|
// on startup no one should be marked as logged
|
||||||
assertThat(dataSource.getLoggedPlayers(), empty());
|
assertThat(dataSource.isLogged("user"), equalTo(false));
|
||||||
|
assertThat(dataSource.isLogged("bobby"), equalTo(false));
|
||||||
|
|
||||||
// Mark user as logged
|
// Mark user as logged
|
||||||
dataSource.setLogged("user");
|
dataSource.setLogged("user");
|
||||||
@ -361,15 +362,16 @@ public abstract class AbstractDataSourceIntegrationTest {
|
|||||||
// Set bobby logged and unlog user
|
// Set bobby logged and unlog user
|
||||||
dataSource.setLogged("bobby");
|
dataSource.setLogged("bobby");
|
||||||
dataSource.setUnlogged("user");
|
dataSource.setUnlogged("user");
|
||||||
assertThat(dataSource.getLoggedPlayers(),
|
|
||||||
contains(hasAuthBasicData("bobby", "Bobby", "your@email.com", "123.45.67.89")));
|
assertThat(dataSource.isLogged("user"), equalTo(false));
|
||||||
|
assertThat(dataSource.isLogged("bobby"), equalTo(true));
|
||||||
|
|
||||||
// Set both as logged (even if Bobby already is logged)
|
// Set both as logged (even if Bobby already is logged)
|
||||||
dataSource.setLogged("user");
|
dataSource.setLogged("user");
|
||||||
dataSource.setLogged("bobby");
|
dataSource.setLogged("bobby");
|
||||||
dataSource.purgeLogged();
|
dataSource.purgeLogged();
|
||||||
assertThat(dataSource.isLogged("user"), equalTo(false));
|
assertThat(dataSource.isLogged("user"), equalTo(false));
|
||||||
assertThat(dataSource.getLoggedPlayers(), empty());
|
assertThat(dataSource.isLogged("bobby"), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -400,4 +402,18 @@ public abstract class AbstractDataSourceIntegrationTest {
|
|||||||
assertThat(email1.getValue(), equalTo("user@example.org"));
|
assertThat(email1.getValue(), equalTo("user@example.org"));
|
||||||
assertThat(email2, is(DataSourceResult.unknownPlayer()));
|
assertThat(email2, is(DataSourceResult.unknownPlayer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldGetLoggedPlayersWithoutEmail() {
|
||||||
|
// given
|
||||||
|
DataSource dataSource = getDataSource();
|
||||||
|
dataSource.setLogged("bobby");
|
||||||
|
dataSource.setLogged("user");
|
||||||
|
|
||||||
|
// when
|
||||||
|
List<String> loggedPlayersWithEmptyMail = dataSource.getLoggedPlayersWithEmptyMail();
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertThat(loggedPlayersWithEmptyMail, contains("Bobby"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user