### Question:
MesosStateService { public JsonArray sandbox(final String appName) throws JSONException { JSONObject state = fetch(stateUrl); JsonArray result = new JsonArray(); for (JSONObject each : findExecutors(state.getJSONArray("frameworks"), appName)) { JSONArray slaves = state.getJSONArray("slaves"); String slaveHost = null; for (int i = 0; i < slaves.length(); i++) { JSONObject slave = slaves.getJSONObject(i); if (each.getString("slave_id").equals(slave.getString("id"))) { slaveHost = slave.getString("pid").split("@")[1]; } } Preconditions.checkNotNull(slaveHost); JSONObject slaveState = fetch(String.format("http: String workDir = slaveState.getJSONObject("flags").getString("work_dir"); Collection<JSONObject> executorsOnSlave = findExecutors(slaveState.getJSONArray("frameworks"), appName); for (JSONObject executorOnSlave : executorsOnSlave) { JsonObject r = new JsonObject(); r.addProperty("hostname", slaveState.getString("hostname")); r.addProperty("path", executorOnSlave.getString("directory").replace(workDir, "")); result.add(r); } } return result; } MesosStateService(final CoordinatorRegistryCenter regCenter); static synchronized void register(final String hostName, final int port); static synchronized void deregister(); JsonArray sandbox(final String appName); Collection<ExecutorStateInfo> executors(final String appName); Collection<ExecutorStateInfo> executors();  }### Answer:
@Test public void assertSandbox() throws Exception { Mockito.when(registryCenter.getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("d8701508-41b7-471e-9b32-61cf824a660d-0000"); MesosStateService service = new MesosStateService(registryCenter); JsonArray sandbox = service.sandbox("foo_app"); Assert.assertThat(sandbox.size(), Is.is(1)); Assert.assertThat(sandbox.get(0).getAsJsonObject().get("hostname").getAsString(), Is.is("127.0.0.1")); Assert.assertThat(sandbox.get(0).getAsJsonObject().get("path").getAsString(), Is.is("/slaves/d8701508-41b7-471e-9b32-61cf824a660d-S0/" + "frameworks/d8701508-41b7-471e-9b32-61cf824a660d-0000/executors/foo_app@-@d8701508-41b7-471e-9b32-61cf824a660d-S0/runs/53fb4af7-aee2-44f6-9e47-6f418d9f27e1")); }