PageRenderTime 845ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/galaxy-integration-tests/src/test/java/com/proofpoint/galaxy/integration/TestCliIntegration.java

http://github.com/dain/galaxy-server
Java | 541 lines | 445 code | 96 blank | 0 comment | 16 complexity | d7cc8ea862890283685cec02e5a7448d MD5 | raw file
  1. package com.proofpoint.galaxy.integration;
  2. import com.google.common.collect.ArrayListMultimap;
  3. import com.google.common.collect.ImmutableList;
  4. import com.google.common.collect.ImmutableMap;
  5. import com.google.common.collect.ListMultimap;
  6. import com.google.inject.Binder;
  7. import com.google.inject.Guice;
  8. import com.google.inject.Injector;
  9. import com.google.inject.Module;
  10. import com.google.inject.util.Modules;
  11. import com.proofpoint.configuration.ConfigurationFactory;
  12. import com.proofpoint.configuration.ConfigurationModule;
  13. import com.proofpoint.event.client.NullEventModule;
  14. import com.proofpoint.galaxy.cli.Config;
  15. import com.proofpoint.galaxy.cli.Galaxy;
  16. import com.proofpoint.galaxy.cli.Galaxy.GalaxyCommand;
  17. import com.proofpoint.galaxy.cli.Galaxy.GalaxyCommanderCommand;
  18. import com.proofpoint.galaxy.cli.InteractiveUser;
  19. import com.proofpoint.galaxy.cli.OutputFormat;
  20. import com.proofpoint.galaxy.coordinator.Coordinator;
  21. import com.proofpoint.galaxy.coordinator.CoordinatorMainModule;
  22. import com.proofpoint.galaxy.coordinator.InMemoryStateManager;
  23. import com.proofpoint.galaxy.coordinator.LocalProvisionerModule;
  24. import com.proofpoint.galaxy.coordinator.Provisioner;
  25. import com.proofpoint.galaxy.coordinator.StateManager;
  26. import com.proofpoint.galaxy.coordinator.TestingMavenRepository;
  27. import com.proofpoint.galaxy.shared.AgentStatusRepresentation;
  28. import com.proofpoint.galaxy.shared.Assignment;
  29. import com.proofpoint.galaxy.shared.CoordinatorStatusRepresentation;
  30. import com.proofpoint.galaxy.shared.SlotLifecycleState;
  31. import com.proofpoint.galaxy.shared.SlotStatusRepresentation;
  32. import com.proofpoint.http.server.testing.TestingHttpServer;
  33. import com.proofpoint.http.server.testing.TestingHttpServerModule;
  34. import com.proofpoint.jaxrs.JaxrsModule;
  35. import com.proofpoint.json.JsonModule;
  36. import com.proofpoint.node.NodeModule;
  37. import org.testng.annotations.AfterClass;
  38. import org.testng.annotations.BeforeClass;
  39. import org.testng.annotations.BeforeMethod;
  40. import org.testng.annotations.Test;
  41. import java.io.File;
  42. import java.util.List;
  43. import java.util.Map;
  44. import java.util.UUID;
  45. import static com.google.inject.Scopes.SINGLETON;
  46. import static com.proofpoint.galaxy.shared.AssignmentHelper.APPLE_ASSIGNMENT;
  47. import static com.proofpoint.galaxy.shared.AssignmentHelper.APPLE_ASSIGNMENT_2;
  48. import static com.proofpoint.galaxy.shared.AssignmentHelper.BANANA_ASSIGNMENT;
  49. import static com.proofpoint.galaxy.shared.AssignmentHelper.BANANA_ASSIGNMENT_EXACT;
  50. import static com.proofpoint.galaxy.shared.FileUtils.createTempDir;
  51. import static com.proofpoint.galaxy.shared.FileUtils.deleteRecursively;
  52. import static org.testng.Assert.assertEquals;
  53. import static org.testng.Assert.assertNotNull;
  54. import static org.testng.Assert.assertNull;
  55. import static org.testng.Assert.assertTrue;
  56. public class TestCliIntegration
  57. {
  58. private TestingHttpServer coordinatorServer;
  59. private Coordinator coordinator;
  60. private InMemoryStateManager stateManager;
  61. private MockLocalProvisioner provisioner;
  62. private File binaryRepoDir;
  63. private File localBinaryRepoDir;
  64. private File expectedStateDir;
  65. private File serviceInventoryCacheDir;
  66. private Config config;
  67. private MockInteractiveUser interactiveUser;
  68. private MockOutputFormat outputFormat;
  69. @BeforeClass
  70. public void setUp()
  71. throws Exception
  72. {
  73. try {
  74. binaryRepoDir = TestingMavenRepository.createBinaryRepoDir();
  75. }
  76. catch (Exception e) {
  77. e.printStackTrace();
  78. throw e;
  79. }
  80. localBinaryRepoDir = createTempDir("localBinaryRepoDir");
  81. expectedStateDir = createTempDir("expected-state");
  82. serviceInventoryCacheDir = createTempDir("service-inventory-cache");
  83. Map<String, String> coordinatorProperties = ImmutableMap.<String, String>builder()
  84. .put("node.environment", "prod")
  85. .put("galaxy.version", "123")
  86. .put("coordinator.binary-repo", binaryRepoDir.toURI().toString())
  87. .put("coordinator.default-group-id", "prod")
  88. .put("coordinator.binary-repo.local", localBinaryRepoDir.toString())
  89. .put("coordinator.status.expiration", "1s")
  90. .put("coordinator.agent.default-config", "@agent.config")
  91. .put("coordinator.aws.access-key", "my-access-key")
  92. .put("coordinator.aws.secret-key", "my-secret-key")
  93. .put("coordinator.aws.agent.ami", "ami-0123abcd")
  94. .put("coordinator.aws.agent.keypair", "keypair")
  95. .put("coordinator.aws.agent.security-group", "default")
  96. .put("coordinator.aws.agent.default-instance-type", "t1.micro")
  97. .put("coordinator.expected-state.dir", expectedStateDir.getAbsolutePath())
  98. .put("coordinator.service-inventory.cache-dir", serviceInventoryCacheDir.getAbsolutePath())
  99. .build();
  100. Injector coordinatorInjector = Guice.createInjector(new TestingHttpServerModule(),
  101. new NodeModule(),
  102. new JsonModule(),
  103. new JaxrsModule(),
  104. new NullEventModule(),
  105. new CoordinatorMainModule(),
  106. Modules.override(new LocalProvisionerModule()).with(new Module()
  107. {
  108. @Override
  109. public void configure(Binder binder)
  110. {
  111. binder.bind(StateManager.class).to(InMemoryStateManager.class).in(SINGLETON);
  112. binder.bind(Provisioner.class).to(MockLocalProvisioner.class).in(SINGLETON);
  113. }
  114. }),
  115. new ConfigurationModule(new ConfigurationFactory(coordinatorProperties)));
  116. coordinatorServer = coordinatorInjector.getInstance(TestingHttpServer.class);
  117. coordinator = coordinatorInjector.getInstance(Coordinator.class);
  118. stateManager = (InMemoryStateManager) coordinatorInjector.getInstance(StateManager.class);
  119. provisioner = (MockLocalProvisioner) coordinatorInjector.getInstance(Provisioner.class);
  120. provisioner.autoStartInstances = true;
  121. coordinator.start();
  122. coordinatorServer.start();
  123. }
  124. @BeforeMethod
  125. public void resetState()
  126. throws Exception
  127. {
  128. provisioner.clearCoordinators();
  129. coordinator.updateAllCoordinators();
  130. assertEquals(coordinator.getCoordinators().size(), 1);
  131. provisioner.clearAgents();
  132. coordinator.updateAllAgents();
  133. assertTrue(coordinator.getAgents().isEmpty());
  134. stateManager.clearAll();
  135. assertTrue(coordinator.getAllSlotStatus().isEmpty());
  136. config = new Config();
  137. interactiveUser = new MockInteractiveUser(true);
  138. outputFormat = new MockOutputFormat();
  139. }
  140. @AfterClass
  141. public void stopServer()
  142. throws Exception
  143. {
  144. provisioner.clearAgents();
  145. provisioner.clearCoordinators();
  146. if (coordinatorServer != null) {
  147. coordinatorServer.stop();
  148. }
  149. if (binaryRepoDir != null) {
  150. deleteRecursively(binaryRepoDir);
  151. }
  152. if (expectedStateDir != null) {
  153. deleteRecursively(expectedStateDir);
  154. }
  155. if (serviceInventoryCacheDir != null) {
  156. deleteRecursively(serviceInventoryCacheDir);
  157. }
  158. if (localBinaryRepoDir != null) {
  159. deleteRecursively(localBinaryRepoDir);
  160. }
  161. }
  162. @Test
  163. public void testLocalModeHappyPath()
  164. throws Exception
  165. {
  166. execute("environment", "add", "local", coordinatorServer.getBaseUrl().toASCIIString());
  167. execute("show");
  168. assertNotNull(outputFormat.slots);
  169. assertEquals(outputFormat.slots.size(), 0);
  170. assertNull(outputFormat.coordinators);
  171. assertNull(outputFormat.agents);
  172. execute("agent", "show");
  173. assertNull(outputFormat.slots);
  174. assertNull(outputFormat.slots);
  175. assertNull(outputFormat.coordinators);
  176. assertEquals(outputFormat.agents.size(), 0);
  177. execute("agent", "provision");
  178. assertNull(outputFormat.slots);
  179. assertNull(outputFormat.slots);
  180. assertNull(outputFormat.coordinators);
  181. assertEquals(outputFormat.agents.size(), 1);
  182. AgentStatusRepresentation agent = outputFormat.agents.get(0);
  183. execute("coordinator", "show");
  184. assertNull(outputFormat.slots);
  185. assertNull(outputFormat.slots);
  186. assertEquals(outputFormat.coordinators.size(), 1);
  187. assertNull(outputFormat.agents);
  188. execute("install", APPLE_ASSIGNMENT.getConfig(), APPLE_ASSIGNMENT.getBinary());
  189. assertNotNull(outputFormat.slots);
  190. assertEquals(outputFormat.slots.size(), 1);
  191. SlotStatusRepresentation slot = outputFormat.slots.get(0);
  192. UUID slotId = slot.getId();
  193. assertNotNull(slotId);
  194. assertSlotStatus(slot, slotId, APPLE_ASSIGNMENT, SlotLifecycleState.STOPPED, agent);
  195. assertNull(outputFormat.coordinators);
  196. assertEquals(outputFormat.agents.size(), 1);
  197. execute("start", "-c", APPLE_ASSIGNMENT.getConfig());
  198. assertNotNull(outputFormat.slots);
  199. assertEquals(outputFormat.slots.size(), 1);
  200. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT, SlotLifecycleState.RUNNING, agent);
  201. assertNull(outputFormat.coordinators);
  202. assertNull(outputFormat.agents);
  203. execute("reset-to-actual", "-c", APPLE_ASSIGNMENT.getConfig());
  204. assertNotNull(outputFormat.slots);
  205. assertEquals(outputFormat.slots.size(), 1);
  206. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT, SlotLifecycleState.RUNNING, agent);
  207. assertNull(outputFormat.coordinators);
  208. assertNull(outputFormat.agents);
  209. execute("stop", "-c", APPLE_ASSIGNMENT.getConfig());
  210. assertNotNull(outputFormat.slots);
  211. assertEquals(outputFormat.slots.size(), 1);
  212. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT, SlotLifecycleState.STOPPED, agent);
  213. assertNull(outputFormat.coordinators);
  214. assertNull(outputFormat.agents);
  215. execute("restart", "-c", APPLE_ASSIGNMENT.getConfig());
  216. assertNotNull(outputFormat.slots);
  217. assertEquals(outputFormat.slots.size(), 1);
  218. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT, SlotLifecycleState.RUNNING, agent);
  219. assertNull(outputFormat.coordinators);
  220. assertNull(outputFormat.agents);
  221. execute("upgrade", "-c", APPLE_ASSIGNMENT.getConfig(), "2.0", "@2.0");
  222. assertNotNull(outputFormat.slots);
  223. assertEquals(outputFormat.slots.size(), 1);
  224. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT_2, SlotLifecycleState.STOPPED, agent);
  225. assertNull(outputFormat.coordinators);
  226. assertNull(outputFormat.agents);
  227. execute("start", "-c", APPLE_ASSIGNMENT_2.getConfig());
  228. assertNotNull(outputFormat.slots);
  229. assertEquals(outputFormat.slots.size(), 1);
  230. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT_2, SlotLifecycleState.RUNNING, agent);
  231. assertNull(outputFormat.coordinators);
  232. assertNull(outputFormat.agents);
  233. execute("restart", "-c", APPLE_ASSIGNMENT_2.getConfig());
  234. assertNotNull(outputFormat.slots);
  235. assertEquals(outputFormat.slots.size(), 1);
  236. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT_2, SlotLifecycleState.RUNNING, agent);
  237. assertNull(outputFormat.coordinators);
  238. assertNull(outputFormat.agents);
  239. execute("terminate", "-c", APPLE_ASSIGNMENT_2.getConfig());
  240. assertNotNull(outputFormat.slots);
  241. assertEquals(outputFormat.slots.size(), 1);
  242. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT_2, SlotLifecycleState.RUNNING, agent);
  243. assertNull(outputFormat.coordinators);
  244. assertNull(outputFormat.agents);
  245. execute("stop", "-c", APPLE_ASSIGNMENT_2.getConfig());
  246. assertNotNull(outputFormat.slots);
  247. assertEquals(outputFormat.slots.size(), 1);
  248. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT_2, SlotLifecycleState.STOPPED, agent);
  249. assertNull(outputFormat.coordinators);
  250. assertNull(outputFormat.agents);
  251. execute("terminate", "-c", APPLE_ASSIGNMENT_2.getConfig());
  252. assertNotNull(outputFormat.slots);
  253. assertEquals(outputFormat.slots.size(), 1);
  254. assertSlotStatus(outputFormat.slots.get(0), slotId, APPLE_ASSIGNMENT_2, SlotLifecycleState.TERMINATED, agent);
  255. assertNull(outputFormat.coordinators);
  256. assertNull(outputFormat.agents);
  257. execute("show");
  258. assertNotNull(outputFormat.slots);
  259. assertEquals(outputFormat.slots.size(), 0);
  260. assertNull(outputFormat.coordinators);
  261. assertNull(outputFormat.agents);
  262. }
  263. @Test
  264. public void testSlotFilter()
  265. throws Exception
  266. {
  267. execute("environment", "add", "local", coordinatorServer.getBaseUrl().toASCIIString());
  268. execute("agent", "provision");
  269. assertNull(outputFormat.slots);
  270. assertNull(outputFormat.slots);
  271. assertNull(outputFormat.coordinators);
  272. assertEquals(outputFormat.agents.size(), 1);
  273. execute("agent", "provision");
  274. assertNull(outputFormat.slots);
  275. assertNull(outputFormat.slots);
  276. assertNull(outputFormat.coordinators);
  277. assertEquals(outputFormat.agents.size(), 1);
  278. AgentStatusRepresentation agent = outputFormat.agents.get(0);
  279. execute("install", APPLE_ASSIGNMENT.getConfig(), APPLE_ASSIGNMENT.getBinary());
  280. assertNotNull(outputFormat.slots);
  281. assertEquals(outputFormat.slots.size(), 1);
  282. execute("install", APPLE_ASSIGNMENT.getConfig(), APPLE_ASSIGNMENT.getBinary());
  283. assertNotNull(outputFormat.slots);
  284. assertEquals(outputFormat.slots.size(), 1);
  285. execute("install", BANANA_ASSIGNMENT.getConfig(), BANANA_ASSIGNMENT.getBinary());
  286. assertNotNull(outputFormat.slots);
  287. assertEquals(outputFormat.slots.size(), 1);
  288. execute("install", BANANA_ASSIGNMENT.getConfig(), BANANA_ASSIGNMENT.getBinary());
  289. assertNotNull(outputFormat.slots);
  290. assertEquals(outputFormat.slots.size(), 1);
  291. ListMultimap<Assignment, SlotStatusRepresentation> slots;
  292. execute("show");
  293. slots = slotsByAssignment();
  294. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 2);
  295. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 2);
  296. String appleSlotId = slots.get(APPLE_ASSIGNMENT).get(0).getId().toString();
  297. String appleShortSlotId = slots.get(APPLE_ASSIGNMENT).get(0).getShortId();
  298. String bananaSlotId = slots.get(BANANA_ASSIGNMENT_EXACT).get(0).getId().toString();
  299. String bananaShortSlotId = slots.get(BANANA_ASSIGNMENT_EXACT).get(0).getShortId();
  300. execute("show", "--all");
  301. slots = slotsByAssignment();
  302. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 2);
  303. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 2);
  304. execute("show", "-u", appleSlotId);
  305. slots = slotsByAssignment();
  306. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 1);
  307. assertEquals(slots.get(APPLE_ASSIGNMENT).get(0).getId().toString(), appleSlotId);
  308. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 0);
  309. execute("show", "-u", appleShortSlotId, "-u", bananaShortSlotId);
  310. slots = slotsByAssignment();
  311. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 1);
  312. assertEquals(slots.get(APPLE_ASSIGNMENT).get(0).getId().toString(), appleSlotId);
  313. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 1);
  314. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).get(0).getId().toString(), bananaSlotId);
  315. execute("show", "-u", appleSlotId, "-u", bananaSlotId);
  316. slots = slotsByAssignment();
  317. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 1);
  318. assertEquals(slots.get(APPLE_ASSIGNMENT).get(0).getId().toString(), appleSlotId);
  319. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 1);
  320. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).get(0).getId().toString(), bananaSlotId);
  321. execute("show", "-c", APPLE_ASSIGNMENT.getConfig());
  322. slots = slotsByAssignment();
  323. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 2);
  324. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 0);
  325. execute("show", "-b", APPLE_ASSIGNMENT.getBinary());
  326. slots = slotsByAssignment();
  327. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 2);
  328. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 0);
  329. execute("show", "-h", agent.getInternalHost());
  330. slots = slotsByAssignment();
  331. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 2);
  332. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 2);
  333. execute("show", "-h", agent.getInternalIp());
  334. slots = slotsByAssignment();
  335. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 2);
  336. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 2);
  337. execute("show", "-h", agent.getExternalHost());
  338. slots = slotsByAssignment();
  339. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 2);
  340. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 2);
  341. execute("show", "-m", agent.getInstanceId());
  342. slots = slotsByAssignment();
  343. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 1);
  344. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 1);
  345. execute("start", "-b", BANANA_ASSIGNMENT_EXACT.getBinary());
  346. slots = slotsByAssignment();
  347. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 0);
  348. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 2);
  349. execute("start", "-s", SlotLifecycleState.RUNNING.toString());
  350. slots = slotsByAssignment();
  351. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 0);
  352. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 2);
  353. execute("start", "-s", SlotLifecycleState.STOPPED.toString());
  354. slots = slotsByAssignment();
  355. assertEquals(slots.get(APPLE_ASSIGNMENT).size(), 2);
  356. assertEquals(slots.get(BANANA_ASSIGNMENT_EXACT).size(), 0);
  357. }
  358. private ListMultimap<Assignment, SlotStatusRepresentation> slotsByAssignment()
  359. {
  360. assertNotNull(outputFormat.slots);
  361. ArrayListMultimap<Assignment, SlotStatusRepresentation> slotsByAssignment = ArrayListMultimap.create();
  362. for (SlotStatusRepresentation slot : outputFormat.slots) {
  363. slotsByAssignment.put(new Assignment(slot.getBinary(), slot.getConfig()), slot);
  364. }
  365. return slotsByAssignment;
  366. }
  367. private void assertSlotStatus(SlotStatusRepresentation slot,
  368. UUID expectedSlotId,
  369. Assignment expectedAssignment,
  370. SlotLifecycleState expectedState,
  371. AgentStatusRepresentation expectedAgent)
  372. {
  373. assertEquals(slot.getId(), expectedSlotId);
  374. if (expectedState != SlotLifecycleState.TERMINATED) {
  375. assertEquals(slot.getBinary(), expectedAssignment.getBinary());
  376. assertEquals(slot.getConfig(), expectedAssignment.getConfig());
  377. assertNotNull(slot.getInstallPath());
  378. }
  379. else {
  380. assertNull(slot.getBinary());
  381. assertNull(slot.getConfig());
  382. assertNull(slot.getInstallPath());
  383. }
  384. assertEquals(slot.getStatus(), expectedState.toString());
  385. assertEquals(slot.getInstanceId(), expectedAgent.getInstanceId());
  386. assertTrue(slot.getLocation().startsWith(expectedAgent.getLocation()));
  387. assertTrue(slot.getLocation().endsWith(slot.getShortLocation()));
  388. assertTrue(slot.getSelf().toASCIIString().startsWith(expectedAgent.getSelf().toASCIIString()));
  389. assertTrue(slot.getExternalUri().toASCIIString().startsWith(expectedAgent.getExternalUri().toASCIIString()));
  390. }
  391. private void execute(String... args)
  392. throws Exception
  393. {
  394. outputFormat.clear();
  395. GalaxyCommand command = Galaxy.GALAXY_PARSER.parse(ImmutableList.<String>builder().add("--debug").add(args).build());
  396. command.config = config;
  397. if (command instanceof GalaxyCommanderCommand) {
  398. GalaxyCommanderCommand galaxyCommanderCommand = (GalaxyCommanderCommand) command;
  399. galaxyCommanderCommand.execute("local", outputFormat, interactiveUser);
  400. }
  401. else {
  402. command.execute();
  403. }
  404. }
  405. private static class MockOutputFormat implements OutputFormat
  406. {
  407. private List<CoordinatorStatusRepresentation> coordinators;
  408. private List<AgentStatusRepresentation> agents;
  409. private List<SlotStatusRepresentation> slots;
  410. public void clear()
  411. {
  412. coordinators = null;
  413. agents = null;
  414. slots = null;
  415. }
  416. @Override
  417. public void displayCoordinators(Iterable<CoordinatorStatusRepresentation> coordinators)
  418. {
  419. this.coordinators = ImmutableList.copyOf(coordinators);
  420. }
  421. @Override
  422. public void displayAgents(Iterable<AgentStatusRepresentation> agents)
  423. {
  424. this.agents = ImmutableList.copyOf(agents);
  425. }
  426. @Override
  427. public void displaySlots(Iterable<SlotStatusRepresentation> slots)
  428. {
  429. this.slots = ImmutableList.copyOf(slots);
  430. }
  431. }
  432. private static class MockInteractiveUser implements InteractiveUser
  433. {
  434. private boolean answer;
  435. private MockInteractiveUser(boolean answer)
  436. {
  437. this.answer = answer;
  438. }
  439. @Override
  440. public boolean ask(String question, boolean defaultValue)
  441. {
  442. return answer;
  443. }
  444. }
  445. }