Skip to content

Commit a3c48f4

Browse files
authoredJul 20, 2019
[INTERNAL][CORE] Move User Preferences to User Object
Integration of the User Preference Store into the User Object. 1. this removes the duplicate storage of user color 2. removing (unlikely but possible) data races where a user has already been added to a session but the preference store is not set or user already removed 3. removes some code duplication
1 parent fe4f99e commit a3c48f4

21 files changed

+114
-167
lines changed
 

‎core/src/saros/negotiation/NegotiationFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private TransferType getTransferType(ISarosSession session, JID remoteAddress) {
213213
throw new IllegalStateException("User <" + user + "> is not part of the session.");
214214
}
215215

216-
String type = session.getUserProperties(user).getString(ProjectNegotiationTypeHook.KEY_TYPE);
216+
String type = user.getPreferences().getString(ProjectNegotiationTypeHook.KEY_TYPE);
217217
if (type.isEmpty()) {
218218
throw new IllegalArgumentException("Missing TransferType for User: " + user);
219219
}

‎core/src/saros/negotiation/OutgoingSessionNegotiation.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import saros.net.xmpp.discovery.DiscoveryManager;
2626
import saros.preferences.IPreferenceStore;
2727
import saros.preferences.PreferenceStore;
28-
import saros.session.ColorNegotiationHook;
2928
import saros.session.ISarosSession;
3029
import saros.session.ISarosSessionManager;
3130
import saros.session.User;
@@ -184,9 +183,7 @@ public Status start(IProgressMonitor monitor) {
184183

185184
IPreferenceStore clientProperties = new PreferenceStore();
186185
applySessionParameters(
187-
actualSessionParameters,
188-
sarosSession.getUserProperties(sarosSession.getHost()),
189-
clientProperties);
186+
actualSessionParameters, sarosSession.getHost().getPreferences(), clientProperties);
190187

191188
User newUser = completeInvitation(clientProperties, monitor);
192189

@@ -461,14 +458,16 @@ private User completeInvitation(IPreferenceStore properties, IProgressMonitor mo
461458

462459
monitor.setTaskName("Synchronizing user list...");
463460

464-
int clientColorID = properties.getInt(ColorNegotiationHook.KEY_INITIAL_COLOR);
465-
int clientFavoriteColorID = properties.getInt(ColorNegotiationHook.KEY_FAV_COLOR);
466-
User user = new User(getPeer(), false, false, clientColorID, clientFavoriteColorID);
461+
User user = new User(getPeer(), false, false, properties);
467462

468463
synchronized (REMOVE_ME_IF_SESSION_ADD_USER_IS_THREAD_SAFE) {
469-
sarosSession.addUser(user, properties);
464+
sarosSession.addUser(user);
470465
log.debug(
471-
this + " : added " + getPeer() + " to the current session, colorID: " + clientColorID);
466+
this
467+
+ " : added "
468+
+ getPeer()
469+
+ " to the current session, colorID: "
470+
+ user.getColorID());
472471

473472
/* *
474473
*

‎core/src/saros/session/ISarosSession.java

+1-12
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import saros.filesystem.IProject;
3131
import saros.filesystem.IResource;
3232
import saros.net.xmpp.JID;
33-
import saros.preferences.IPreferenceStore;
3433
import saros.session.IActivityConsumer.Priority;
3534
import saros.session.User.Permission;
3635
import saros.synchronize.StopManager;
@@ -102,9 +101,8 @@ public void changePermission(User user, Permission permission)
102101
* will be noticed about the new user.
103102
*
104103
* @param user the user that is to be added
105-
* @param preferences the initial properties of the new user
106104
*/
107-
public void addUser(User user, IPreferenceStore preferences);
105+
public void addUser(User user);
108106

109107
/**
110108
* Informs all listeners that a user now has Projects and can process {@link IResourceActivity}s.
@@ -178,15 +176,6 @@ public void changePermission(User user, Permission permission)
178176
*/
179177
public User getUser(JID jid);
180178

181-
/**
182-
* Given a user, this method will return this users session properties.
183-
*
184-
* @param user the user to get the preferences for
185-
* @return Properties of the given user or <code>null</code> if the user is not known to the
186-
* session
187-
*/
188-
public IPreferenceStore getUserProperties(User user);
189-
190179
/**
191180
* Given a JID (resource qualified or not), will return the resource qualified JID associated with
192181
* this user or <code>null</code> if no user for the given JID exists in the session.

‎core/src/saros/session/User.java

+17-44
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
1-
/*
2-
* DPP - Serious Distributed Pair Programming
3-
* (c) Freie Universität Berlin - Fachbereich Mathematik und Informatik - 2006
4-
* (c) Riad Djemili - 2006
5-
*
6-
* This program is free software; you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation; either version 1, or (at your option)
9-
* any later version.
10-
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19-
*/
201
package saros.session;
212

223
import saros.net.xmpp.JID;
4+
import saros.preferences.IPreferenceStore;
5+
import saros.preferences.PreferenceStore;
236

247
/**
258
* A user is a representation of a person sitting in front of an eclipse instance for the use in one
@@ -44,27 +27,24 @@ public enum Permission {
4427
READONLY_ACCESS
4528
}
4629

30+
private final JID jid;
4731
private final boolean isHost;
48-
4932
private final boolean isLocal;
50-
51-
private final JID jid;
52-
53-
private volatile int colorID;
54-
55-
private final int favoriteColorID;
33+
private final IPreferenceStore preferences;
5634

5735
private volatile Permission permission = Permission.WRITE_ACCESS;
58-
5936
private volatile boolean isInSession;
6037

61-
public User(JID jid, boolean isHost, boolean isLocal, int colorID, int favoriteColorID) {
62-
38+
public User(JID jid, boolean isHost, boolean isLocal, IPreferenceStore preferences) {
6339
this.jid = jid;
6440
this.isHost = isHost;
6541
this.isLocal = isLocal;
66-
this.colorID = colorID;
67-
this.favoriteColorID = favoriteColorID;
42+
43+
if (preferences == null) {
44+
this.preferences = new PreferenceStore();
45+
} else {
46+
this.preferences = preferences;
47+
}
6848
}
6949

7050
/**
@@ -153,11 +133,11 @@ public boolean equals(Object obj) {
153133
}
154134

155135
public int getColorID() {
156-
return colorID;
136+
return preferences.getInt(ColorNegotiationHook.KEY_INITIAL_COLOR);
157137
}
158138

159139
public int getFavoriteColorID() {
160-
return favoriteColorID;
140+
return preferences.getInt(ColorNegotiationHook.KEY_FAV_COLOR);
161141
}
162142

163143
/**
@@ -186,19 +166,12 @@ public boolean isClient() {
186166
return !isHost();
187167
}
188168

189-
/**
190-
* FOR INTERNAL USE ONLY
191-
*
192-
* @param colorID
193-
* @deprecated this must only be called by the component that handles color changes
194-
*/
195-
@Deprecated
196-
public void setColorID(int colorID) {
197-
this.colorID = colorID;
198-
}
199-
200169
/** FOR INTERNAL USE ONLY */
201170
public void setInSession(boolean isInSession) {
202171
this.isInSession = isInSession;
203172
}
173+
174+
public IPreferenceStore getPreferences() {
175+
return preferences;
176+
}
204177
}

‎core/src/saros/session/internal/ChangeColorManager.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import saros.repackaged.picocontainer.Startable;
2020
import saros.session.AbstractActivityConsumer;
2121
import saros.session.AbstractActivityProducer;
22+
import saros.session.ColorNegotiationHook;
2223
import saros.session.IActivityConsumer;
2324
import saros.session.IActivityConsumer.Priority;
2425
import saros.session.ISessionListener;
@@ -130,7 +131,7 @@ public synchronized void start() {
130131

131132
if (!isValidColorID(colorID)) {
132133
colorID = getNextAvailableColorID();
133-
session.getLocalUser().setColorID(colorID);
134+
setUserColor(session.getLocalUser(), colorID);
134135
} else removeColorIdFromPool(colorID);
135136
} else {
136137
/*
@@ -223,7 +224,7 @@ private void handleChangeColorActivity(ChangeColorActivity activity) {
223224
removeColorIdFromPool(colorID);
224225

225226
// this fails if a new copy is returned !
226-
affected.setColorID(colorID);
227+
setUserColor(affected, colorID);
227228
} else {
228229

229230
assert session.isHost() : "only the session host can assign a color id";
@@ -233,7 +234,7 @@ private void handleChangeColorActivity(ChangeColorActivity activity) {
233234

234235
addColorIdToPool(affected.getColorID());
235236

236-
affected.setColorID(colorID);
237+
setUserColor(affected, colorID);
237238
fireChanges = true;
238239
}
239240
}
@@ -246,6 +247,10 @@ private void handleChangeColorActivity(ChangeColorActivity activity) {
246247
session.userColorChanged(affected);
247248
}
248249

250+
private void setUserColor(User user, int colorId) {
251+
user.getPreferences().setValue(ColorNegotiationHook.KEY_INITIAL_COLOR, colorId);
252+
}
253+
249254
/*
250255
* original algorithm by: fzieris and pschlott, modified and integrated by
251256
* srossbach
@@ -370,7 +375,7 @@ private void updateColorAndUserPools(Map<User, Integer> assignedColors) {
370375

371376
// make sure user uses the colorId we calculated
372377
User user = entry.getKey();
373-
user.setColorID(colorId);
378+
setUserColor(user, colorId);
374379
}
375380
}
376381

‎core/src/saros/session/internal/SarosSession.java

+3-28
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import saros.preferences.IPreferenceStore;
5555
import saros.repackaged.picocontainer.MutablePicoContainer;
5656
import saros.repackaged.picocontainer.annotations.Inject;
57-
import saros.session.ColorNegotiationHook;
5857
import saros.session.IActivityConsumer;
5958
import saros.session.IActivityConsumer.Priority;
6059
import saros.session.IActivityHandlerCallback;
@@ -110,9 +109,6 @@ public final class SarosSession implements ISarosSession {
110109

111110
private final ConcurrentHashMap<JID, User> participants = new ConcurrentHashMap<JID, User>();
112111

113-
private final ConcurrentHashMap<User, IPreferenceStore> userProperties =
114-
new ConcurrentHashMap<User, IPreferenceStore>();
115-
116112
private final SessionListenerDispatch listenerDispatch = new SessionListenerDispatch();
117113

118114
private final User hostUser;
@@ -361,7 +357,7 @@ public boolean hasWriteAccess() {
361357
* proper initialization etc. of User objects !
362358
*/
363359
@Override
364-
public void addUser(final User user, IPreferenceStore properties) {
360+
public void addUser(final User user) {
365361

366362
// TODO synchronize this method !
367363

@@ -377,9 +373,6 @@ public void addUser(final User user, IPreferenceStore properties) {
377373
log.error("user " + user + " added twice to SarosSession", new StackTrace());
378374
throw new IllegalArgumentException();
379375
}
380-
if (this.userProperties.putIfAbsent(user, properties) != null) {
381-
log.warn("user " + user + " already has properties");
382-
}
383376

384377
/*
385378
*
@@ -493,9 +486,6 @@ public void removeUser(final User user) {
493486
log.error("tried to remove user " + user + " who was never added to the session");
494487
return;
495488
}
496-
if (userProperties.remove(user) == null) {
497-
log.error("tried to remove properties of user " + user + " that were never initialized");
498-
}
499489

500490
activitySequencer.unregisterUser(user);
501491

@@ -665,13 +655,6 @@ public User getUser(JID jid) {
665655
return user;
666656
}
667657

668-
@Override
669-
public IPreferenceStore getUserProperties(User user) {
670-
if (user == null) throw new IllegalArgumentException("user is null");
671-
672-
return userProperties.get(user);
673-
}
674-
675658
@Override
676659
public JID getResourceQualifiedJID(JID jid) {
677660

@@ -1074,25 +1057,17 @@ private SarosSession(
10741057

10751058
assert localUserJID != null;
10761059

1077-
int localColorID = localProperties.getInt(ColorNegotiationHook.KEY_INITIAL_COLOR);
1078-
int localFavoriteColorID = localProperties.getInt(ColorNegotiationHook.KEY_FAV_COLOR);
1079-
localUser = new User(localUserJID, host == null, true, localColorID, localFavoriteColorID);
1080-
1060+
localUser = new User(localUserJID, host == null, true, localProperties);
10811061
localUser.setInSession(true);
10821062

10831063
if (host == null) {
10841064
hostUser = localUser;
10851065
participants.put(hostUser.getJID(), hostUser);
1086-
userProperties.put(hostUser, localProperties);
10871066
} else {
1088-
int hostColorID = hostProperties.getInt(ColorNegotiationHook.KEY_INITIAL_COLOR);
1089-
int hostFavoriteColorID = hostProperties.getInt(ColorNegotiationHook.KEY_FAV_COLOR);
1090-
hostUser = new User(host, true, false, hostColorID, hostFavoriteColorID);
1067+
hostUser = new User(host, true, false, hostProperties);
10911068
hostUser.setInSession(true);
10921069
participants.put(hostUser.getJID(), hostUser);
10931070
participants.put(localUser.getJID(), localUser);
1094-
userProperties.put(hostUser, hostProperties);
1095-
userProperties.put(localUser, localProperties);
10961071
}
10971072

10981073
sessionContainer = context.createChildContainer();

‎core/src/saros/session/internal/UserInformationHandler.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import saros.net.xmpp.JID;
2323
import saros.preferences.PreferenceStore;
2424
import saros.repackaged.picocontainer.Startable;
25+
import saros.session.ColorNegotiationHook;
2526
import saros.session.ISarosSession;
2627
import saros.session.User;
2728

@@ -293,10 +294,14 @@ private void handleUserListUpdate(Packet packet) {
293294
continue;
294295
}
295296

296-
user = new User(userEntry.jid, false, false, userEntry.colorID, userEntry.favoriteColorID);
297+
PreferenceStore preferences = new PreferenceStore();
298+
preferences.setValue(ColorNegotiationHook.KEY_INITIAL_COLOR, userEntry.colorID);
299+
preferences.setValue(ColorNegotiationHook.KEY_FAV_COLOR, userEntry.favoriteColorID);
300+
301+
user = new User(userEntry.jid, false, false, preferences);
297302

298303
user.setPermission(userEntry.permission);
299-
session.addUser(user, new PreferenceStore());
304+
session.addUser(user);
300305

301306
} else if ((userEntry.flags & UserListEntry.USER_REMOVED) != 0) {
302307
user = session.getUser(userEntry.jid);

‎core/test/junit/saros/activities/ActivityOptimizerTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
public class ActivityOptimizerTest {
1717

18-
private final User alice = new User(new JID("alice@junit"), true, true, 0, 0);
19-
private final User bob = new User(new JID("bob@junit"), false, false, 0, 0);
18+
private final User alice = new User(new JID("alice@junit"), true, true, null);
19+
private final User bob = new User(new JID("bob@junit"), false, false, null);
2020

2121
private IPath fooPath;
2222
private IPath barPath;

‎core/test/junit/saros/communication/extensions/ActivitiesExtensionProviderTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class ActivitiesExtensionProviderTest {
1515

1616
@Test
1717
public void testNoPrettyPrintInMarshalledObjects() throws Exception {
18-
User user = new User(new JID("alice@test"), true, true, 0, 0);
18+
User user = new User(new JID("alice@test"), true, true, null);
1919

2020
IActivity activity = new EditorActivity(user, EditorActivity.Type.ACTIVATED, null);
2121

‎core/test/junit/saros/concurrent/jupiter/test/util/JupiterTestCase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ public ClientSynchronizedDocument[] setUp(int number, String initialText) {
6363
}
6464

6565
public static User createUser(String name) {
66-
return new User(new JID(name + "@jabber.org"), false, true, 0, 0);
66+
return new User(new JID(name + "@jabber.org"), false, true, null);
6767
}
6868
}

‎core/test/junit/saros/editor/colorstorage/ColorIDSetTest.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import org.junit.Before;
1515
import org.junit.Test;
1616
import saros.net.xmpp.JID;
17+
import saros.preferences.IPreferenceStore;
18+
import saros.preferences.PreferenceStore;
19+
import saros.session.ColorNegotiationHook;
1720
import saros.session.User;
1821

1922
public class ColorIDSetTest {
@@ -27,10 +30,16 @@ public void setUp() {
2730
userList = new ArrayList<User>();
2831
userMap = new HashMap<String, UserColorID>();
2932

30-
alice = new User(new JID("alice@saros.org"), false, false, 0, -1);
31-
bob = new User(new JID("bob@saros.org"), false, false, 1, -1);
32-
carl = new User(new JID("carl@lagerfeld.org"), false, false, 2, -1);
33-
dave = new User(new JID("dave@saros.org"), false, false, 0, -1);
33+
alice = createUser("alice@saros.org", 0);
34+
bob = createUser("bob@saros.org", 1);
35+
carl = createUser("carl@lagerfeld.org", 2);
36+
dave = createUser("dave@saros.org", 0);
37+
}
38+
39+
private User createUser(String jid, int color) {
40+
IPreferenceStore preferences = new PreferenceStore();
41+
preferences.setValue(ColorNegotiationHook.KEY_INITIAL_COLOR, color);
42+
return new User(new JID(jid), false, false, preferences);
3443
}
3544

3645
private ColorIDSet createColorIDSet(Collection<User> users) {

‎core/test/junit/saros/misc/xstream/UserConverterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public class UserConverterTest {
2020
@BeforeClass
2121
public static void prepare() {
2222
JID aliceJid = new JID("alice@saros-con");
23-
alice = new User(aliceJid, true, true, 0, 0);
23+
alice = new User(aliceJid, true, true, null);
2424

2525
JID bobJid = new JID("bob@saros-con");
26-
bob = new User(bobJid, false, false, 0, 0);
26+
bob = new User(bobJid, false, false, null);
2727

2828
/* Mocks */
2929
ISarosSession session = EasyMock.createMock(ISarosSession.class);

‎core/test/junit/saros/negotiation/SessionNegotiationTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public class SessionNegotiationTest {
4848
private static final JID ALICE = new JID("alice@test/Saros");
4949
private static final JID BOB = new JID("bob@test/Saros");
5050

51-
private static final User HOST = new User(ALICE, true, true, 0, 0);
52-
private static final User INVITEE = new User(BOB, true, true, 0, 0);
51+
private static final User HOST = new User(ALICE, true, true, null);
52+
private static final User INVITEE = new User(BOB, true, true, null);
5353

5454
private volatile Thread aliceNegotiationThread;
5555
private volatile Thread bobNegotiationThread;
@@ -110,7 +110,7 @@ public void setup() throws Exception {
110110

111111
aliceSession = createNiceMock(ISarosSession.class);
112112

113-
aliceSession.addUser(eq(INVITEE), anyObject(IPreferenceStore.class));
113+
aliceSession.addUser(eq(INVITEE));
114114
expectLastCall().once();
115115

116116
bobSession = createNiceMock(ISarosSession.class);

‎core/test/junit/saros/session/internal/ActivityQueuerTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
public class ActivityQueuerTest {
3232

33-
private static final User ALICE = new User(new JID("Alice"), true, true, 0, 0);
34-
private static final User BOB = new User(new JID("Bob"), false, false, 0, 0);
33+
private static final User ALICE = new User(new JID("Alice"), true, true, null);
34+
private static final User BOB = new User(new JID("Bob"), false, false, null);
3535

3636
private static IProject SHARED_PROJECT;
3737
private static IProject NOT_SHARED_PROJECT;

‎core/test/junit/saros/session/internal/ActivitySequencerTest.java

+20-22
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import saros.net.IReceiver;
2222
import saros.net.ITransmitter;
2323
import saros.net.xmpp.JID;
24-
import saros.preferences.IPreferenceStore;
25-
import saros.preferences.PreferenceStore;
2624
import saros.session.User;
2725
import saros.test.fakes.net.FakeConnectionFactory;
2826
import saros.test.fakes.net.FakeConnectionFactory.FakeConnectionFactoryResult;
@@ -54,7 +52,7 @@ public void setID(String id) {
5452
* needed
5553
*/
5654
@Override
57-
public void addUser(User user, IPreferenceStore properties) {
55+
public void addUser(User user) {
5856
users.add(user);
5957
}
6058

@@ -108,8 +106,8 @@ public void setUp() {
108106
sessionStubAlice = new SequencerSessionStub();
109107
sessionStubBob = new SequencerSessionStub();
110108

111-
aliceUser = new User(ALICE_JID, true, true, 0, 0);
112-
bobUser = new User(BOB_JID, false, true, 0, 0);
109+
aliceUser = new User(ALICE_JID, true, true, null);
110+
bobUser = new User(BOB_JID, false, true, null);
113111

114112
sessionStubAlice.setLocalUser(aliceUser);
115113
sessionStubBob.setLocalUser(bobUser);
@@ -198,7 +196,7 @@ public void testUnregisterUserOnTransmissionFailure() {
198196

199197
aliceSequencer.start();
200198

201-
User bobUserInAliceSession = new User(BOB_JID, false, false, 0, 0);
199+
User bobUserInAliceSession = new User(BOB_JID, false, false, null);
202200

203201
aliceSequencer.registerUser(bobUserInAliceSession);
204202

@@ -225,11 +223,11 @@ public void testSendAndFlushAndReceiveAndOrder() {
225223
aliceSequencer.start();
226224
bobSequencer.start();
227225

228-
User bobUserInAliceSession = new User(BOB_JID, false, false, 0, 0);
229-
User aliceUserInBobSession = new User(ALICE_JID, true, false, 0, 0);
226+
User bobUserInAliceSession = new User(BOB_JID, false, false, null);
227+
User aliceUserInBobSession = new User(ALICE_JID, true, false, null);
230228

231-
sessionStubAlice.addUser(bobUserInAliceSession, new PreferenceStore());
232-
sessionStubBob.addUser(aliceUserInBobSession, new PreferenceStore());
229+
sessionStubAlice.addUser(bobUserInAliceSession);
230+
sessionStubBob.addUser(aliceUserInBobSession);
233231

234232
aliceSequencer.registerUser(bobUserInAliceSession);
235233
bobSequencer.registerUser(aliceUserInBobSession);
@@ -261,11 +259,11 @@ public void testSendWithoutRegisteredUser() {
261259
aliceSequencer.start();
262260
bobSequencer.start();
263261

264-
User bobUserInAliceSession = new User(BOB_JID, false, false, 0, 0);
265-
User aliceUserInBobSession = new User(ALICE_JID, true, false, 0, 0);
262+
User bobUserInAliceSession = new User(BOB_JID, false, false, null);
263+
User aliceUserInBobSession = new User(ALICE_JID, true, false, null);
266264

267-
sessionStubAlice.addUser(bobUserInAliceSession, new PreferenceStore());
268-
sessionStubBob.addUser(aliceUserInBobSession, new PreferenceStore());
265+
sessionStubAlice.addUser(bobUserInAliceSession);
266+
sessionStubBob.addUser(aliceUserInBobSession);
269267

270268
bobSequencer.registerUser(aliceUserInBobSession);
271269

@@ -293,11 +291,11 @@ public void testReceiveWithoutRegisteredUser() {
293291
aliceSequencer.start();
294292
bobSequencer.start();
295293

296-
User bobUserInAliceSession = new User(BOB_JID, false, false, 0, 0);
297-
User aliceUserInBobSession = new User(ALICE_JID, true, false, 0, 0);
294+
User bobUserInAliceSession = new User(BOB_JID, false, false, null);
295+
User aliceUserInBobSession = new User(ALICE_JID, true, false, null);
298296

299-
sessionStubAlice.addUser(bobUserInAliceSession, new PreferenceStore());
300-
sessionStubBob.addUser(aliceUserInBobSession, new PreferenceStore());
297+
sessionStubAlice.addUser(bobUserInAliceSession);
298+
sessionStubBob.addUser(aliceUserInBobSession);
301299

302300
aliceSequencer.registerUser(bobUserInAliceSession);
303301

@@ -326,11 +324,11 @@ public void testSendAndReceiveWithDifferendSessionIDs() {
326324
aliceSequencer.start();
327325
bobSequencer.start();
328326

329-
User bobUserInAliceSession = new User(BOB_JID, false, false, 0, 0);
330-
User aliceUserInBobSession = new User(ALICE_JID, true, false, 0, 0);
327+
User bobUserInAliceSession = new User(BOB_JID, false, false, null);
328+
User aliceUserInBobSession = new User(ALICE_JID, true, false, null);
331329

332-
sessionStubAlice.addUser(bobUserInAliceSession, new PreferenceStore());
333-
sessionStubBob.addUser(aliceUserInBobSession, new PreferenceStore());
330+
sessionStubAlice.addUser(bobUserInAliceSession);
331+
sessionStubBob.addUser(aliceUserInBobSession);
334332

335333
aliceSequencer.registerUser(bobUserInAliceSession);
336334
bobSequencer.registerUser(aliceUserInBobSession);

‎core/test/junit/saros/session/internal/UserInformationHandlerTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void testSynchronizeWithEmptyRemoteUsersCollection() {
4343

4444
UserInformationHandler handler = new UserInformationHandler(session, transmitter, receiver);
4545

46-
User alice = new User(new JID("alice@test/Saros"), false, false, 0, 0);
46+
User alice = new User(new JID("alice@test/Saros"), false, false, null);
4747

4848
handler.start();
4949

@@ -58,7 +58,7 @@ public void testSynchronizeWithEmptyUserData() {
5858

5959
UserInformationHandler handler = new UserInformationHandler(session, transmitter, receiver);
6060

61-
User alice = new User(new JID("alice@test/Saros"), false, false, 0, 0);
61+
User alice = new User(new JID("alice@test/Saros"), false, false, null);
6262

6363
handler.start();
6464

@@ -73,7 +73,7 @@ public void testSynchronizeWithNullUserData() {
7373

7474
UserInformationHandler handler = new UserInformationHandler(session, transmitter, receiver);
7575

76-
User alice = new User(new JID("alice@test/Saros"), false, false, 0, 0);
76+
User alice = new User(new JID("alice@test/Saros"), false, false, null);
7777

7878
handler.start();
7979

@@ -88,7 +88,7 @@ public void testSynchronizeWithEmptyAndNullUserData() {
8888

8989
UserInformationHandler handler = new UserInformationHandler(session, transmitter, receiver);
9090

91-
User alice = new User(new JID("alice@test/Saros"), false, false, 0, 0);
91+
User alice = new User(new JID("alice@test/Saros"), false, false, null);
9292

9393
handler.start();
9494

@@ -104,8 +104,8 @@ public void testSynchronizeWhileUserLeavesSession() {
104104

105105
UserInformationHandler handler = new UserInformationHandler(session, transmitter, receiver);
106106

107-
User alice = new User(new JID("alice@test/Saros"), false, false, 0, 0);
108-
User bob = new User(new JID("bob@test/Saros"), false, false, 0, 0);
107+
User alice = new User(new JID("alice@test/Saros"), false, false, null);
108+
User bob = new User(new JID("bob@test/Saros"), false, false, null);
109109

110110
alice.setInSession(false);
111111

‎core/test/junit/saros/synchronize/StopManagerTest.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public Object answer() throws Throwable {
6262
});
6363
alicesSession.removeActivityConsumer(isA(IActivityConsumer.class));
6464

65-
alicesAlice = new User(new JID("alice"), true, true, 1, -1);
66-
alicesBob = new User(new JID("bob"), false, false, 2, -1);
67-
alicesCarl = new User(new JID("carl"), false, false, 3, -1);
65+
alicesAlice = new User(new JID("alice"), true, true, null);
66+
alicesBob = new User(new JID("bob"), false, false, null);
67+
alicesCarl = new User(new JID("carl"), false, false, null);
6868

6969
alicesAlice.setInSession(true);
7070
alicesBob.setInSession(true);
@@ -102,9 +102,9 @@ public Object answer() throws Throwable {
102102
});
103103
bobsSession.removeActivityConsumer(isA(IActivityConsumer.class));
104104

105-
bobsAlice = new User(new JID("alice"), true, false, 1, -1);
106-
bobsBob = new User(new JID("bob"), false, true, 2, -1);
107-
bobsCarl = new User(new JID("carl"), false, false, 3, -1);
105+
bobsAlice = new User(new JID("alice"), true, false, null);
106+
bobsBob = new User(new JID("bob"), false, true, null);
107+
bobsCarl = new User(new JID("carl"), false, false, null);
108108

109109
bobsAlice.setInSession(true);
110110
bobsBob.setInSession(true);
@@ -141,9 +141,9 @@ public Object answer() throws Throwable {
141141
});
142142
carlsSession.removeActivityConsumer(isA(IActivityConsumer.class));
143143

144-
carlsAlice = new User(new JID("alice"), true, false, 1, -1);
145-
carlsBob = new User(new JID("bob"), false, false, 2, -1);
146-
carlsCarl = new User(new JID("carl"), false, true, 3, -1);
144+
carlsAlice = new User(new JID("alice"), true, false, null);
145+
carlsBob = new User(new JID("bob"), false, false, null);
146+
carlsCarl = new User(new JID("carl"), false, true, null);
147147

148148
carlsAlice.setInSession(true);
149149
carlsBob.setInSession(true);
@@ -536,7 +536,7 @@ public void created(IActivity activity) {
536536
}
537537

538538
private static User rewriteUser(User user) {
539-
User copy = new User(user.getJID(), user.isHost(), !user.isLocal(), user.getColorID(), -1);
539+
User copy = new User(user.getJID(), user.isHost(), !user.isLocal(), null);
540540
copy.setInSession(true);
541541
return copy;
542542
}

‎core/test/junit/saros/test/stubs/SarosSessionStub.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import saros.filesystem.IProject;
1111
import saros.filesystem.IResource;
1212
import saros.net.xmpp.JID;
13-
import saros.preferences.IPreferenceStore;
1413
import saros.session.IActivityConsumer;
1514
import saros.session.IActivityConsumer.Priority;
1615
import saros.session.IActivityProducer;
@@ -69,11 +68,6 @@ public User getUser(JID jid) {
6968
throw new RuntimeException("Unexpected call to Stub");
7069
}
7170

72-
@Override
73-
public IPreferenceStore getUserProperties(User user) {
74-
throw new RuntimeException("Unexpected call to Stub");
75-
}
76-
7771
@Override
7872
public JID getResourceQualifiedJID(JID jid) {
7973
throw new RuntimeException("Unexpected call to Stub");
@@ -130,7 +124,7 @@ public void exec(List<IActivity> activities) {
130124
}
131125

132126
@Override
133-
public void addUser(User user, IPreferenceStore properties) {
127+
public void addUser(User user) {
134128
throw new RuntimeException("Unexpected call to Stub");
135129
}
136130

‎eclipse/test/junit/saros/editor/internal/ContributionAnnotationManagerTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void setUp() {
4646
@Test
4747
public void testHistoryRemoval() {
4848

49-
User alice = new User(new JID("alice@test"), false, false, 0, 0);
49+
User alice = new User(new JID("alice@test"), false, false, null);
5050

5151
AnnotationModel model = new AnnotationModel();
5252

@@ -66,7 +66,7 @@ public void testHistoryRemoval() {
6666

6767
@Test
6868
public void testHistoryRemovalAfterRefresh() {
69-
User alice = new User(new JID("alice@test"), false, false, 0, 0);
69+
User alice = new User(new JID("alice@test"), false, false, null);
7070

7171
AnnotationModel model = new AnnotationModel();
7272

@@ -85,8 +85,8 @@ public void testHistoryRemovalAfterRefresh() {
8585
@Test
8686
public void testAnnotationSplit() {
8787

88-
final User alice = new User(new JID("alice@test"), false, false, 0, 0);
89-
final User bob = new User(new JID("bob@test"), false, false, 0, 0);
88+
final User alice = new User(new JID("alice@test"), false, false, null);
89+
final User bob = new User(new JID("bob@test"), false, false, null);
9090

9191
final AnnotationModel model = new AnnotationModel();
9292

‎eclipse/test/junit/saros/feedback/StatisticCollectorTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public class StatisticCollectorTest {
3838

3939
private static ISarosSession createSessionMock(final List<Object> sessionListeners) {
4040
ISarosSession session = EasyMock.createMock(ISarosSession.class);
41-
final User bob = new User(new JID("bob"), false, false, 1, -1);
42-
final User alice = new User(new JID("alice"), false, false, 2, -1);
41+
final User bob = new User(new JID("bob"), false, false, null);
42+
final User alice = new User(new JID("alice"), false, false, null);
4343
final List<User> participants = new LinkedList<User>();
4444
participants.add(bob);
4545
participants.add(alice);

‎eclipse/test/junit/saros/project/FileActivityConsumerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private SPath createPathMockForFile(IFile file) {
113113

114114
private FileActivity createFileActivity(IFile file, byte[] content) {
115115
return new FileActivity(
116-
new User(new JID("foo@bar"), true, true, 0, 0),
116+
new User(new JID("foo@bar"), true, true, null),
117117
Type.CREATED,
118118
Purpose.ACTIVITY,
119119
createPathMockForFile(file),

0 commit comments

Comments
 (0)
Please sign in to comment.