Skip to content

temp: gestalt-di migration changes #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/main/java/org/terasology/moduletestingenvironment/Engines.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
public class Engines {
private static final Logger logger = LoggerFactory.getLogger(Engines.class);

protected final Set<String> dependencies = Sets.newHashSet("engine");
protected final Set<String> dependencies = Sets.newHashSet("engine", "unittest");
protected String worldGeneratorUri = ModuleTestingEnvironment.DEFAULT_WORLD_GENERATOR;
protected boolean doneLoading;
protected Context hostContext;
Expand Down Expand Up @@ -236,13 +236,17 @@
logger.info("Install path does not appear to be a module: {}", installPath);
}
} catch (IOException e) {
logger.warn("Could not read install path as module at " + installPath);

Check warning on line 239 in src/main/java/org/terasology/moduletestingenvironment/Engines.java

View check run for this annotation

Terasology Jenkins.io / PMD

GuardLogStatementJavaUtil

HIGH: Logger calls should be surrounded by log level guards.
}
}

protected void mockPathManager() {
PathManager originalPathManager = PathManager.getInstance();
pathManager = Mockito.spy(originalPathManager);
if (org.mockito.Mockito.mockingDetails(originalPathManager).isMock()) {
pathManager = originalPathManager;
} else {
pathManager = Mockito.spy(originalPathManager);
}
Mockito.when(pathManager.getModulePaths()).thenReturn(Collections.emptyList());
pathManagerCleaner = new PathManagerProvider.Cleaner(originalPathManager, pathManager);
PathManagerProvider.setPathManager(pathManager);
Expand All @@ -257,7 +261,7 @@
doneLoading = false;
terasologyEngine.subscribeToStateChange(() -> {
GameState newState = terasologyEngine.getState();
logger.debug("New engine state is {}", terasologyEngine.getState());

Check warning on line 264 in src/main/java/org/terasology/moduletestingenvironment/Engines.java

View check run for this annotation

Terasology Jenkins.io / PMD

GuardLogStatementJavaUtil

HIGH: Logger calls should be surrounded by log level guards.
if (newState instanceof StateIngame) {
hostContext = newState.getContext();
if (hostContext == null) {
Expand All @@ -283,18 +287,20 @@
}

void connectToHost(TerasologyEngine client, MainLoop mainLoop) {
CoreRegistry.put(Config.class, client.getFromEngineContext(Config.class));
Context clientContext = client.createChildContext();
clientContext.put(Config.class, client.getFromEngineContext(Config.class));
CoreRegistry.setContext(clientContext);
JoinStatus joinStatus = null;
try {
joinStatus = client.getFromEngineContext(NetworkSystem.class).join("localhost", 25777);
joinStatus = clientContext.get(NetworkSystem.class).join("localhost", 25777);
} catch (InterruptedException e) {
logger.warn("Interrupted while joining: ", e);
}

client.changeState(new StateLoading(joinStatus));
CoreRegistry.put(GameEngine.class, client);
clientContext.put(GameEngine.class, client);

// TODO: subscribe to state change and return an asynchronous result

Check warning on line 303 in src/main/java/org/terasology/moduletestingenvironment/Engines.java

View check run for this annotation

Terasology Jenkins.io / Open Tasks Scanner

TODO

NORMAL: subscribe to state change and return an asynchronous result
// so that we don't need to pass mainLoop to here.
mainLoop.runUntil(() -> client.getState() instanceof StateIngame);
}
Expand Down
Loading