Skip to content
Permalink
Browse files

fix: Add ability to set roster for a profile

  • Loading branch information...
rhwood committed Aug 6, 2019
1 parent 404f0a9 commit 1ccd7401497c920bf2c60abaf0bfb157be43e15c
@@ -209,4 +209,16 @@ public Roster getRoster(@CheckForNull Profile profile) {
return roster;
}

/**
* Set the roster for the profile.
*
* @param profile the profile to set the roster for
* @param roster the roster for the profile
* @return the roster just set, so this method can be used in a chain
*/
@Nonnull
public Roster setRoster(@CheckForNull Profile profile, @Nonnull Roster roster) {
rosters.put(profile, roster);
return getRoster(profile);
}
}
@@ -6,7 +6,9 @@
import javax.servlet.http.HttpServletResponse;
import jmri.InstanceManager;
import jmri.jmrit.roster.Roster;
import jmri.jmrit.roster.RosterConfigManager;
import jmri.jmrit.roster.RosterEntry;
import jmri.profile.ProfileManager;
import jmri.server.json.JSON;
import jmri.server.json.JsonException;
import jmri.server.json.JsonHttpServiceTestBase;
@@ -31,7 +33,9 @@ public void setUp() throws Exception {
super.setUp();
service = new JsonRosterHttpService(mapper);
JUnitUtil.initConfigureManager();
InstanceManager.setDefault(Roster.class, new Roster("java/test/jmri/server/json/roster/data/roster.xml"));
JUnitUtil.initRosterConfigManager();
InstanceManager.getDefault(RosterConfigManager.class).setRoster(ProfileManager.getDefault().getActiveProfile(),
new Roster("java/test/jmri/server/json/roster/data/roster.xml"));
}

@After
@@ -12,7 +12,9 @@
import jmri.InstanceManager;
import jmri.JmriException;
import jmri.jmrit.roster.Roster;
import jmri.jmrit.roster.RosterConfigManager;
import jmri.jmrit.roster.RosterEntry;
import jmri.profile.ProfileManager;
import jmri.server.json.JSON;
import jmri.server.json.JsonException;
import jmri.server.json.JsonMockConnection;
@@ -39,7 +41,9 @@ public void setUp() throws Exception {

connection = new JsonMockConnection((DataOutputStream) null);

InstanceManager.setDefault(Roster.class, new Roster("java/test/jmri/server/json/roster/data/roster.xml"));
JUnitUtil.initRosterConfigManager();
InstanceManager.getDefault(RosterConfigManager.class).setRoster(ProfileManager.getDefault().getActiveProfile(),
new Roster("java/test/jmri/server/json/roster/data/roster.xml"));
connection = new JsonMockConnection((DataOutputStream) null);
}

0 comments on commit 1ccd740

Please sign in to comment.
You can’t perform that action at this time.